?
Solved

Creating a Verity collection from a database table?

Posted on 2004-10-13
4
Medium Priority
?
177 Views
Last Modified: 2013-12-24
I've been working on a document management project for a few months and have almost completed it.  I am at the stage where I need to create a search interface for my documents and have successfully done so using Verity.  I created a collection and then indexed it using the "Path" attribute.  This works well but I did run into some problems because I store information about the documents in a database and couldn't relate this information to the output of the Verity search results.  I read up on this and found an example in the CFDOCS online.  I'm not sure if I am understanding this right but it looks like I may be able to create a collection using my database table and also add a few custom fields in that I could use in my search as well.  

Here's my question:  Is it even possible to populate a collection using my database that would actually index the files on the server?  I need the search to look into the files content and not just the data I have saved in the database.

Can I add custom1 and custom2 attributes to the collection and will those be searchable and returned in the output?  

Here's what I have:
A table named Documents that has a DocumentID, Description, Filename, Full_Path, FolderID  
I think I could do a query to get all of the documents in the database and then output that around a cfindex but I tried that and it froze up my laptop.  I don't know if this will actually create a good index either.  The reason I want to do this is so that I can allow the filename and description that I have saved in the database to be searched and found along with the actual contents of the document.  Otherwise I have to create two seperate collections, one for the content and one for the database data.

Here's the code I tried if this makes sense:

 <cfquery name="getDocs" datasource="#application.datasource#">
   SELECT D.DOCID,D.DOCNAME,D.DOCTITLE,D.FULLPATH,D.Filename
   FROM DOC D
</cfquery>

<cfoutput query="getDocs">
     <p>#docname# #doctitle# #fullpath# #filename#p>

<cfindex
collection="Documents"
action="update"
type="file"
query="getDocs"
key="fullpath"
custom1="filename"
custom2="lastname">

</cfoutput>

I'm not sure if I should try to make the key equal the primary key of the database table or the full path to the document?

Thanks for any advice on this one!
0
Comment
Question by:Ike23
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 1400 total points
ID: 12302669
First of all you shouldn't  to put CFOUTPUT around a CFINDEX is going to burn your system up every time. It will reindex the entire collection once for every record in the table. So if you have 100 records, it runs CFINDEX 100 times with no benefit!!!

Secondly, you can't mix TYPE=file with a QUERY. You're either indexing a query or a set of files.
 
The simple answer is to make 2 collections!!!
Index your files with the filename as the key.
Then index your query using the filename as the key.
Then run *2* CFSEARCHes using the filename as the criteria.

Good Luck
0
 
LVL 9

Expert Comment

by:CFDevHead
ID: 12302674
One more thing
Loop over the results to build a single summary string where the keys are the same.
0
 
LVL 4

Author Comment

by:Ike23
ID: 12302859
So this is totally wrong on the ColdFusion docs site?

http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/indexs21.htm

Here's the part I'm referring to:

<cfquery name="bookquery"
    datasource="book">
    SELECT * FROM book where bookid='file'
</cfquery>

<cfoutput query="bookquery">
    #url#,#description# <br>

<cfindex collection="snippets" action="update" type="file" query="bookquery" key="description" urlpath="url">

</cfoutput>

What I am trying to do is create a collection of the actual files but also include a few custom values that I can attach to each record and then also search.  This example does in fact lead me to believe that you can index a collection with a query with type="file".  

I did make a colleciton using the type="path" which works well and returns values based on a form search.  The problem is that it only searches the actual content and I want to be able to search for file name, author etc.  

Are you saying to create another collection using the database option and then do a cfsearch at the same time?

Thansk for your input,

Tim
0
 
LVL 4

Author Comment

by:Ike23
ID: 12351638
I just decided to create 2 seperate collections and search them at the same time.  Now that is working to my satisfaction I am going through each section to update the collections each time a document is added/edited/moved/deleted etc.  I almost have it all working except for the delete section.  I can get the File collection to delete the file from the collection but when I try to delete the record from the database collection it doesn't work.  I can still search for the file and it comes up but then there is no matching record in the database which causes an error.  Is there something I am missing here?  Here is what I am using:

      <cflock name="verity" timeout="60">
            <CFSET IndexCollection2 = "Database1">
            <cfindex
            collection="#IndexCollection2#"
            action="delete"
                  key="#get_doc.DOCID#">
      </cflock>

No errors get thrown when I do this but I know that the record is still in the collection.  When I update the collection I use the Primary key field named DOCID.  Is that correct when I pass the value to  cfindex that it should look for the key and delete the data relating to that key?

Thanks for your help!
0

Featured Post

The Ideal Solution for Multi-Display Applications

Check out ATEN’s VS1912 12-Port DP Video Wall Media Player at InfoComm 2017. Kerri describes how easy it is to design creative video walls in asymmetric layouts and schedule detailed playlists ahead of time with its advanced scheduling feature.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question