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

  1. #1

    Default Boolean Searches

    I am trying to implement a boolean type search . The current search that I have
    searches for exact matches, if the input has multiple words. I want the search
    to take the multiple words and ouput all those records that have all those
    words, irrepective of the order in which they occur in each record. Here's the
    code that I have - can anyone spot a mistake, because it is not working, and it
    is too late and I am getting a headache ;-)

    <cfif search_category is "DESCRIPTION">
    <cfset temp_query = Replace(TRIM(UCASE(query))," ","+","ALL")> <!-- Replace
    all spaces with + to creat a list-->
    <cfif ListLen(temp_query,'+') gt 1> <!-- Check to see List has more than one
    element -->
    <cfloop index="i" from="1" to="#ListLen(temp_query,'+')#">
    <cfset temp_query_i = ListGetAt(temp_query,i,'+')>
    </cfloop>
    </cfif>
    </cfif>

    <cfif search_category is "DESCRIPTION">
    <cfif ListLen(temp_query,'+') gt 1>
    <cfloop index="i" from="1" to="#ListLen(temp_query,'+')#">
    upper(DESCRIPTION) like '%#TRIM(UCASE(temp_query_i))#%' <cfif i lt
    ListLen(temp_query,'+')>AND</cfif>
    </cfloop>
    <cfelse>
    upper(DESCRIPTION) like '%#TRIM(UCASE(query))#%'
    </cfif>
    </cfif>

    freezer9 Guest

  2. Similar Questions and Discussions

    1. Using Boolean Operators in Searches
      Problem: Other than searching for single words or using the "Exact Phrase Match," I can't get the searches of documents to return the proper results,...
    2. doing searches - need help really quickly
      hello, a client im doing a webpage for wants me to add a search type thing on the site - the site is fully flash. what the search is for is for...
    3. Keyword Searches
      Hi everyone, Does anyone know how to add a keyword search to a site? Daniel Park Executive Director La Paz International
    4. Full-text searches and ASP.NET
      Hi. I have to implement a search mechanism for the site I am developing. The choosen option for the project was to use full-text searches in our...
    5. Help with speeding up searches
      "Jeroen Braun" <jnjbraun@euronet.nl> wrote in message news:<3e72995a$0$57483$1b62eedf@news.euronet.nl>... The table was not built by me. I was...
  3. #2

    Default Re: Boolean Searches

    Never mind - got a simple solution from [url]http://tutorial234.easycfm.com/[/url] Works
    like a charm! <CFQUERY NAME='searchresults' DATASOURCE='yourdatasource'>
    SELECT * FROM table WHERE 0=0 AND ( <cfloop index='i'
    list='#form.searchkeyword#' delimiters=' '> <cfoutput>fieldname LIKE
    '%#i#%' AND </cfoutput> </cfloop> '%%') </CFQUERY>

    freezer9 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