How to get an exact substring match search with wildcards for Solr in ColdFusion? - Stack Overflow

I am trying to implement a search in ColdFusion (with indexing through Solr) where it gets a match on e

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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信