我正在尝试实现solr的自动建议这是我在solrconfig.xml文件中所做的更改
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<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.TSTLookupFactory</str>
<str name="field">displayName</str> <!-- the indexed field to derive suggestions from -->
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
当我尝试使用示例输入查询为'p'
时http://localhost:8983/solr/food/suggest?q=p&wt=json&indent=true
它返回5个字
"pizza", "potato", "pasta", "protein", "premium"
但是在displayName字段中,我得到了像paneer,palak等字样,这些字样没有显示为什么会这样?
答案 0 :(得分:0)
您是否可以在配置中添加以下内容并运行以下查询。 在进行这些更改后,不要忘记重新加载solr核心。
http://localhost:8983/solr/food/suggest?suggest=true&suggest.build=true&suggest.dictionary=suggest&wt=json&suggest.q=p&suggest.count=10
{{1}}