Solved

Creating a Verity collection from a database table?

Posted on 2004-10-13
4
169 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
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
CFDevHead earned 350 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

Network it in WD Red

There's an industry-leading WD Red drive for every compatible NAS system to help fulfill your data storage needs. With drives up to 8TB, WD Red offers a wide array of solutions for customers looking to build the biggest, best-performing NAS storage solution.  

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now