Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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....
    5. 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,...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139