Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Verity Search Engine

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
I am trying to implement the Verity search engine. The first thing I want to seach is a discussion board. I created a collection in the Verity Administrator called "Messages". I indexed using the following code:

Code:
<body>
<!--- Run a query on entire message table --->
<CFQUERY NAME=&quot;GetMessageTable&quot;
		DATASOURCE=&quot;#Application.Datasource#&quot;
		DBTYPE=&quot;ODBC&quot;>
		SELECT	*
		FROM	MessageTable
</CFQUERY>

<!--- Index the results --->
<CFINDEX ACTION=&quot;UPDATE&quot;
         COLLECTION=&quot;Messages&quot;
         KEY=&quot;MessageID&quot;
         TYPE=&quot;CUSTOM&quot;
         TITLE=&quot;Subject&quot;
         QUERY=&quot;GetMessageTable&quot;
         BODY=&quot;MsgSubject,MsgMessage&quot;>
</body>

When I try to run a search against it, I get an error that it can't open the collection. What am I doing wrong? Thanks for any assistance.
 
You need to run a CFINDEX action=&quot;CREATE&quot; first...

Sometimes things go awry and you may need to either &quot;repair&quot; or &quot;delete&quot;....

There is a complete &quot;Verity Manager&quot; here you can use to get you started.

 
I created the collection through the Cold Fusion Administrator. I also tried to run CFINDEX with ACTION=&quot;CREATE&quot;, but I got an error saying that &quot;CREATE&quot; is not a valid option for CFINDEX. I will try the Verity Manager, and see what happens. I appreciate the input, thanks!
 
OK, VerityManager worked. I guess it didn't work when I tried to create a collection through the Cold Fusion Administrator, but using CFCOLLECTION, it does. Thanks! :)
 
Is there a way to check weather a verity collection has been properly populated with file documents.

I have created a collection and populated it with document files. When I do CFSEARCH, I got nothing returned.
<code>
<CFSEARCH
NAME=&quot;cfsearchname&quot;
COLLECTION=&quot;collectionname&quot;
TYPE=&quot;Simple&quot;
CRITERIA=&quot;#SearchText#&quot;>

<cfif #articlesearch.RecordCount# GT 0>--->
<!---Display the Record and match count--->
<cfoutput>#ArticleSearch.RecordsSearched# pages searched for: #SearchText#. Found: #ArticleSearch.RecordCount#
</cfoutput>
<code>

search result:
pages searched for: searchtext, 0 Found

Thanks for your help!
 
Did you index the collection before you tried to search it? Or is that what you mean by populating it? If you are indexing the results of a query, make sure your query returned the results you expected. See the link in the second message of this thread. You will find an application called Verity Manager that I have found quite useful.

The basic steps to using Verity are:
1)Create a collection using the CFCOLLECTION tag.
2)Index the collection with the CFINDEX tag. (I indexed the results of a query. I query my database to retreive discussion board messages and index them so they are searchable.)

Verity Manager will give you all the tools you need to do this.

Good luck! If I can be of any more assistance, let me know! Calista :-X
Jedi Knight,
Champion of the Force
 
Hi, thanks for your reply.

Yes, I indexed the collection before trying to search against it. Here is the code I used to index the collection (I was successful to index a database table and do search, but no luck with document files):

<code>
<!--- Populate the collection with files --->
<cfif isdefined (&quot;form.dofilesindex&quot;)>

<cfindex collection=&quot;#form.indexcollectname#&quot;
action=&quot;#form.actionb#&quot;
type=&quot;#form.type#&quot;
key=&quot;#form.key#&quot;
extensions=&quot;html, htm, cfm, cfml, dbm, dbml, doc, ppt, xls, pdf, gif, jpg&quot;
urlpath=&quot; recursion=&quot;yes&quot;>
</code>
 
I see. I haven't tried to do documents, yet, but I'll need to before too long. Here is some code from Verity Manager ,which I would encourage you to download and play with.(Why reinvent something?) Indexing documents requires a few more steps. I haven't tested this code, but you'll get the idea.
Code:
<!---Set the Default Collection Name Here--->
<cfset Name = &quot;PageIndex&quot;>

<!---Define the Path Variables--->
<cfset FullPath = GetcurrentTemplatePath()>
<cfset ThisFilePath = GetDirectoryFromPath(FullPath)>
<cfset ThisFileName = GetFileFromPath(FullPath)>
<cfset DirectoryList = &quot;#ThisFilePath#&quot;>

<cfcase value=&quot;Update&quot;>
<!---This variable will hold all the files found--->
<cfset FileList = &quot;&quot;>
<cfloop list=&quot;#FileList#&quot; index=&quot;File&quot;>
  <cffile action=&quot;read&quot; file=&quot;#File#&quot; variable=&quot;ParseMe&quot;>
  
  <cfset Title=&quot;Untitled&quot;>

  <!---Fetch Title--->
  <cfif #REFindNoCase(&quot;<h[0-9]&quot;,ParseMe,1)# is not 0>
    <cfset start=#find(&quot;>&quot;,ParseMe,REFindNoCase(&quot;<h[0-9]&quot;,ParseMe,1))# + 1>
    <cfset end=#find(&quot;<&quot;,ParseMe,start)#>
    <cfset length = end - start>
    <cfset title=#mid(ParseMe,start,length)#>
  </cfif>  

<!---Test Code--->  
  <cfoutput>  
  #File# <b>#Title#</b><br>
  </cfoutput>
<!---Remove Common tags--->
<cfset ParseMe = REReplaceNoCase(ParseMe,&quot;<[^>]*>&quot;,&quot;&quot;,&quot;all&quot;)>

<!---Remove Noise Words--->
<cfset NoiseWords =
&quot;a,an,and,at,as,are,all,be,but,by,can,do,for,get,got,here,I,if,it,is,in,like,may,not,our,or,of,on,that,then,the,they,there,to,which,we,you,your&quot;>

<cfloop list=&quot;#NoiseWords#&quot; index=&quot;Noise&quot;>
<cfset ParseMe = REReplaceNoCase(ParseMe,&quot;[[:space:]]#Noise#[[:space:]]&quot;,&quot; &quot;,&quot;all&quot;)>
</cfloop>	

<!---Remove Extra Space--->
<cfloop from=&quot;1&quot; to=&quot;10&quot; index=&quot;loop&quot;>
<cfset ParseMe = REReplaceNoCase(ParseMe,&quot;[[:space:]]+[[:space:]]&quot;,&quot; &quot;,&quot;all&quot;)>
</cfloop>

<!---Resolve Web Root--->
<cfset WebPath= ReplaceNoCase(File,Form.SitePathRoot,Form.SiteWebRoot,&quot;all&quot;)>
<cfset WebPath= ReplaceNoCase(WebPath,&quot;\&quot;,&quot;/&quot;,&quot;all&quot;)>

<!---Insert Into Dbase--->
<cftry>
  <cfquery datasource='#DSN#'>
  Insert into Pages(WebPath,FilePath,Title,Contents)
  Values('#WebPath#','#File#','#Title#','#ParseMe#')
  </cfquery>
<cfcatch type='Database'>
  <cfoutput>
  Databse error for:<br>
  file:<b>#Title#</b><br>
  file:<b>#File#</b><br>
  file:<b>#WebPath#</b><br>
  </cfoutput>
</cfcatch>
</cftry>

<!---Test Code--->  
<cfoutput>  
	#File# <b>#Title#</b><br>
	#WebPath#<br><br>
	#htmlCodeFormat('#ParseMe#')#
	<hr>
</cfoutput> 

 <!---Test Code--->  
<cfoutput>  
	#htmlCodeFormat('#ParseMe#')#
	<hr>
</cfoutput> 
</cfloop>

<!---Update the collection--->	
<cfquery datasource=&quot;#DSN#&quot; name=&quot;getContents&quot;>
Select ID,WebPath,FilePath,Title,Contents From Pages
</cfquery>

<cftry>
  <cfindex 
    action=&quot;update&quot; 
    collection=&quot;#Form.CollectionName#&quot;
    query=&quot;getContents&quot;
    key=&quot;ID&quot; 
    title=&quot;title&quot;
    type=&quot;Custom&quot; 
    body=&quot;Contents&quot;
    custom1=&quot;WebPath&quot;>
<cfcatch type=&quot;any&quot;>
  Sorry, an error occurred while trying
  to update your collection. Check that
  the collection exists.
</cfcatch>
</cftry>

</cfcase>

As you can see, you need to process the data a bit more when you are doing documents. Good luck! Calista :-X
Jedi Knight,
Champion of the Force
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top