目前正在Solr 3.6中使用Suggester。我已经将Suggester配置为提供外部字典源。
solrconfig.xml中:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
<bool name="exactMatchFirst">true</bool>
<str name="sourceLocation">D:\source.txt</str>
</lst>
</searchComponent>
的Source.txt:
nokia 2
nokia 5233 3
nokia 5130 2
Symbian 1
samsung 6712 2
htc 2
HTC Wild 6
htc one 7
Nokia 1280 5
当我尝试使用“n”进行搜索时,它会在结果中显示
nokia 5233
nokia 5130
nokia
但“诺基亚1280”不包含结果。
可能是什么原因? 如何在建议者中忽略区分大小写?
答案 0 :(得分:1)
我认为本文将对您有所帮助,https://cwiki.apache.org/confluence/display/solr/Suggester
尝试在建议者中使用“field”参数
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpell</str>
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
<bool name="exactMatchFirst">true</bool>
<str name="field">phoneName</str>
<str name="sourceLocation">D:\source.txt</str>
</lst>
</searchComponent>
字段类型定义
<fieldType class="solr.TextField" name="textSuggest" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
字段定义
<field name="phoneName" type="string" indexed="true" stored="false" required="false" multiValued="false"/>