The following examples show the search syntax used while performing search operations using Solr:
Single word search: The following example shows how to search for a single word in a collection:
<cfsearch name="qsearch1" collection="solr_complex" criteria="Graphics">
Multiple word search: The following example shows how to search a document or query having words "ColdFusion" and "Green" in it:
<cfsearch name="qsearch1"
collection="solr_complex"
criteria="+Green +Coldfusion">
Search with at least one word: The following example shows how search for at least "Coldfusion" OR (Green OR Blue):
<cfsearch name="qsearch1"
collection="solr_complex"
criteria=" +Coldfusion Green Blue">
Search for one word, but not the other: The following example shows how to search for "Green" but NOT "Coldfusion":
<cfsearch name="qsearch1"
collection="solr_complex"
criteria=" -Coldfusion +Green">
Fuzzy search: The following example shows how to search words like roam, roams, foam, foams:
<cfsearch name="qsearch1"
collection="solr_complex"
criteria=" roam~">Alternate way to perform a fuzzy search for "roam":
<cfsearch name="qsearch1"
collection="solr_complex"
criteria="roam~">Searching for higher similarity with roam:
<cfsearch name="qsearch1"
collection="solr_complex"
criteria=" roam~0.8" >
Wildcard search: The following syntax searches for 'test', 'text', 'teat', and so on:
<cfsearch name="qsearch1"
collection="solr_complex"
criteria=" te?t">This example searches for 'test', 'text', 'teeeeeext', and 'texyzt':
<cfsearch name="qsearch1"
collection="solr_complex"
criteria=" te*t">
Note: You cannot use a * or question mark (?) symbol as the first character of a search. |
Proximity search: To search for "apache" and "jakarta" within five words of each other in a document, use the following search:
<cfsearch name="qsearch1"
collection="solr_complex"
criteria="jakarta apache" ~10>
Range Search: Following searches all documents with title between 'fuzzy1.txt' to 'text1.txt':
<cfsearch name="qsearch"
collection="solr_srch"
criteria="title:fuzzy1.txt TO text1.txt">To search a document whose modification date is between a given range:
<cfsearch name="qsearch"
collection="solr_srch"
criteia="modified:20080101 TO 20500101">These
ranges are inclusive of start and end terms. To exclude them, use
curly brackets{} instead.Field search: To search any document whose title contains "fuzzy1.txt"
<cfsearch name="qsearch"
collection="solr_srch"
criteria="title:fuzzy1.txt">Searching for document that contains title as 'fuzzy1.txt' OR 'fuzzy2.txt':
<cfsearch name="qsearch"
collection="solr_srch"
criteria="title:fuzzy?.txt">The following syntax can be used to perform the same search:
<cfsearch name="qsearch"
collection="solr_srch"
criteria= ""title:fuzzy1.txt"" OR ""title:fuzzy2.txt"">Alternatively, you can search using the following syntax:
<cfsearch name="qsearch"
collection="solr_srch"
criteria="title:(test* +fuzzy1*)">
String search:
<cfsearch name="qsearch1"
collection="solr_complex"
criteria="Cold Fusiongava" OR "Internet Tools">
- Searching synonyms: There are two ways to search documents that have synonymous words like 'MB', 'megabyte', 'gig', and so on:
- If collection is not yet created, go to: <cf_home>/solr/multicore/template/conf/synonyms.txt This file contains some default mappings such as 'GB, gig, gigabyte, gigabytes'. Define your synonym mappings in the next row.
- If you want to add a synonym mapping for a collection that is already created, go to <collection_location>/conf/synonyms.txt and define your mapping.Restart the Solr server after defining mapping.