How to make solr suggestion work for a specific field?

不想你离开。 提交于 2019-12-11 04:34:56

问题


I am trying to implement the auto suggest of solr this is the changes that I made in solrconfig.xml file

<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>

when I try to query with sample input as 'p'

http://localhost:8983/solr/food/suggest?q=p&wt=json&indent=true

it returns 5 words

"pizza", "potato", "pasta", "protein", "premium"

but in the displayName field I got words like paneer , palak etc which is not showing up why is it so?


回答1:


Can you added the following to your configuration and run the below query. Don't forget to reload the solr core after putting these changes.

<str name="suggestAnalyzerFieldType">string</str>
<str name="storeDir">suggester_fuzzy_dir</str>

http://localhost:8983/solr/food/suggest?suggest=true&suggest.build=true&suggest.dictionary=suggest&wt=json&suggest.q=p&suggest.count=10



来源:https://stackoverflow.com/questions/32306491/how-to-make-solr-suggestion-work-for-a-specific-field

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