Refine search results for more words in SOLR

一个人想着一个人 提交于 2019-12-11 15:26:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!