admin管理员组

文章数量:1391937

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.

本文标签: How to get an exact substring match search with wildcards for Solr in ColdFusionStack Overflow