问题
I want achieve refine search results when user enter more words by using AND operator between token compassion results.
I tried set qo=AND
but doesn't work and return results which contains only one of entered words.
For instance I using for field searching analyzer like this:
<fieldType name="serch_text" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.EdgeNGramFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
<filter class="solr.TrimFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.EdgeNGramFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory" preserveOriginal="true"/>
<filter class="solr.TrimFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
so for query searching:(hel world)
I want apply analyzer for each word and do AND between results. In practice I expecting something like this:
(hel compare to h, he, hel, hell, hello) AND (world compare to w, wo, ...)
and return results where there are matching both.
回答1:
The argument is q.op=AND
.
The analysis page will also tell you which tokens are being generated on each side, so that output will tell you why both inputs are being hit.
In general, NGram filters (and tokenizer) when both indexing and querying will give you weird results (i.e. hell queried will give a hit against hole, since both will have generated the token h)
Usually you'll only want to ngram when you're indexing (to get autocomplete/start of word functionality).
来源:https://stackoverflow.com/questions/58059007/refine-search-results-for-more-words-in-solr