Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
J?J #1
CFSearch help
I just want to get CFSearch to return SOMETHING!
I hate sounding like a whiner who doesn't read the documentation - I have.
I've done the tutorials [url]http://tutorial121.easycfm.com/[/url]
and another one somewhere where the code didn't work...
I just can't get a verity search to work.
Here's how I understand it.
One creates a collection
one puts in text files (or queries) into the collection using cfindex
one uses Cfsearch to search for a word, and it returns the filename (or
something - not sure what the output should be)
So lets say i have a file named C:\test.txt with contents "this is my body"
How do i get cfsearch to search that text file??
Here's my attempt with what should be THE simplest possible code:
<cfcollection action="delete" collection="TestCol">
<cfcollection action="create" collection="TestCol" path="c:\">
<cfindex
action="update"
collection="testCol"
key="C:\Test.txt"
type="file">
<cfsearch collection="testCol" criteria="body" type="simple" name="ColSearch">
<cfdump var="#colSearch#">
But obviously it doesn't work.
Help Please. Just don't quote me the documentation.
J?J Guest
-
CFsearch and Fusebox
Hi, Can anyone refer me to a simple application/ may be an example that is available and uses Fusebox and CFSeach. I'm hoping there should be... -
cfsearch suggestions language
I have a verity collection created with the language Dutch. In my search, I return the suggestions given by Verity, but these are always in... -
CFSEARCH issue
I am running into a brick wall with a fairly simple search interface I'm working on. Basically, I index a query and then run a CFSEARCH against the... -
CFSEARCH: retrieving rows when StartRow is not 1
We are moving an application from a server on CF 5 to one on CF MX 6.1. In a verity search of a collection, we are displaying 10 hits at a time.... -
How to sort CFSEARCH results
Was wondering if someone might know an easy way to sort the results of a CFSEARCH query. I can query the Verity collection created of documents,... -
The ScareCrow #2
Re: CFSearch help
I think you major problem is the location where you have saved th collection,
in this case "c:\"
But I think the cf server is set to look in "C:\CFusionMX\Verity\Collections\"
I have attached some sample code a page for each action. Create collection,
index collection and search collection
Ken
Create the Collection
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Create a collection</title>
</head>
<body>
<!--- only delete if it has already been created --->
<cfcollection action="DELETE" collection="testCol">
<!--- path is where the collection is stored --->
<cfcollection action="CREATE" collection="testCol"
path="C:\CFusionMX\Verity\Collections\" language="English">
The collection testCol has been created.
</body>
</html>
Index the collection
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Index the collection</title>
</head>
<body>
<!--- this will be the folder that will be indexed --->
<cfset thisPath = ExpandPath("*.*")>
<cfset thisDirectory = GetDirectoryFromPath(thisPath)>
<cfindex collection="testCol"
key="#thisDirectory#"
action="update"
type="path"
urlpath="http://127.0.0.1:8500/testwork/"
extensions=".htm, .html, .cfm"
recurse="Yes"
language="English">
The collection testCol has been indexed.
</body>
</html>
Search the Collection
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfform action="searchCollection.cfm" method="POST" enablecab="No"
name="form1">
Enter search string <cfinput type="Text" name="searchstring" required="No"
size="50">
<input type="submit" name="submit" value="Do Search">
</cfform>
<cfif IsDefined("form.searchstring")>
<cfsearch collection="testCol" name="SearchTest"
criteria="#form.searchstring#">
<!--- print out the search results --->
<cfoutput>
<H2>Search Results</H2>
<P>#SearchTest.recordCount# "hit
<cfif SearchTest.recordcount is not 1>s</cfif>" found
out of #SearchTest.RecordsSearched# total record
<cfif SearchTest.recordcount is not 1>s</cfif>
searched.
<P><I><B>records returned ...</B></I>
<cftable query="SearchTest" colheaders htmltable>
<cfcol header = "SCORE" text = "#score#">
<cfcol header = "TITLE"
text = "<a href = '#url#' target = 'blank'>#title#</A>">
<cfcol header = "SUMMARY" text = "#summary#">
</cftable>
</cfoutput>
</cfif>
</body>
</html>
The ScareCrow Guest
-
Tom Jordahl #3
Re: CFSearch help
Try doing an "empty" search (criteria="") and it should return a query
object with all of the documents in the collection. Use <cfdump var="#q#">
to see the result (which you put in q).
If you get nothing in the query, the index didn't work. Use the new CFMX 7
cfindex "status" attribute and cfdump that out to see any error messages.
Hope this gets you going along with the sample code posted by "The
ScareCrow".
--
Tom Jordahl
Macromedia Server Development
Tom Jordahl Guest
-
J?J #4
Re: CFSearch help
Holy crap I got 1500 records! :D
I never tried type = "path" though... not sure what needs to change to search files but you guys answered my question
thanks
J?J Guest



Reply With Quote

