I am trying to implement a search in ColdFusion (with indexing through Solr) where it gets a match on exact substrings and exact substrings only.
Here's my sample code:
<cfset criteriaString = '*#ARGUMENTS.query_term#*' />
<cfsearch
name="searchResults"
criteria="#criteriaString#"
collection="#courseCollection#"
suggestions="always"
maxrows="1500"
>
Where ARGUMENTS.query_term
is the string that the user searches for. I have a full string of tomato
and this search works great for that - if I search t
, oma
, tomat
, or tomato
, it finds it perfectly with the *
wildcard.
This doesn't work, however, with spaces. I have another string tomato project
, and if I search for tomato pro
or ato p
, it doesn't work.
I tried escaping the space by doing this to my criteriaString
:
<cfset criteriaString = '*#replace(ARGUMENTS.query_term, ' ', '\ ', 'all')#*' />
But that didn't work. I also tried adding quotes around the query term instead:
<cfset criteriaString = '"#replace(ARGUMENTS.query_term, ' ', '\ ', 'all')#"' />
But that didn't work either.
For what it's worth, I believe the tokenizer being used on the fields in my index is the White Space Tokenizer (.html). Any guidance would be greatly appreciated.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744684268a4587818.html
评论列表(0条)