In the current version of Solr supported by Coldfusion, leading wildcard search is not supported by default. A ’*’ as the leading character in a search will not work.
For example this code :
<cfsearch collection=”new” name=”x” criteria=”*title*” categorytree=”books/history/english”>
Will throw an error :
There was a problem while attempting to perform a search.
|Error executing query : org.apache.lucene.queryParser.ParseException: Cannot parse ‘*title*’: ‘*’ or ‘?’ not allowed as first character in WildcardQuery|
Workaround for this is to tweak schema.xm of the collection and add ReversedWildcardFilterFactory filter.
To enable “*criteria*” kinda search go to schema.xml file of the corresponding collection and add this filter to fieldtype with name “text”
<filter class=”solr.ReversedWildcardFilterFactory” withOriginal=”true”
maxPosAsterisk=”2″ maxPosQuestion=”1″ minTrailing=”2″ maxFractionAsterisk=”0″/>
And restart you solr.
But do remember that Using ReversedWildcardFilterFactory will double the size of your dictionary (more or less), maybe drop in performance. So use it only if it is really required by your application