使用 Solr Apache。我想先显示精确匹配,然后在搜索 reault 中显示模糊匹配。
例如,我尝试查找世界测试,但是在响应中,我得到了世界之类的结果,例如cast,latest before results,其中首先包含实际的单词test。
我尝试了这样的查询:test^100 OR test~^5
但这并没有改变结果的顺序,也许查询的这个改变是不正确的。
我的 Solr 配置:
solrconfig.xml
<requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="defType">edismax</str>
<int name="rows">10</int>
<str name="df">text</str>
<str name="wt">php</str>
<str name="sort">score desc</str>
<str name="fl">*, score</str>
<!-- Highlighting defaults -->
<str name="hl">on</str>
<str name="hl.fl">*</str>
<str name ="hl.snippets">10</str>
<str name="hl.fragsize">250</str>
<str name="tie">0.1</str>
<str name="hl.simple.pre"><b style="color:black;background-color:#888888"></str>
<str name="hl.simple.post"></b></str>
<str name="hl.usePhraseHighlighter">true</str>
<str name="hl.highlightMultiTerm">true</str>
<str name ="hl.useFastVectorHighligher">true</str>
<str name ="hl.maxAnalyzedChars">200000</str>
<str name="f.title.hl.alternateField">title</str>
<str name="f.description.hl.alternateField">description</str>
<str name="spellcheck">true</str>
</lst>
schema.xml
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="50"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.TrimFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
<filter class="solr.StandardFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.PorterStemFilterFactory"/>
<filter class="solr.PhoneticFilterFactory" encoder="DoubleMetaphone" inject="true"/>
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
</analyzer>
</fieldType>
谢谢,