Request handle solrconfig.xml Spellchecker

。_饼干妹妹 提交于 2019-11-30 09:43:36

First, don't repeat queryAnalyzerFieldType twice in the component configuration.

It is recommended not to use a /spellcheck handler but instead to bind the spellcheck component to the standard query handler (or dismax if it is what you use) like this:

<requestHandler name="standard" class="solr.SearchHandler" default="true">
 <lst name="defaults">
    ...
 </lst>   
 <arr name="last-components">
    <str>spellcheck</str>
    ...         
 </arr>
</requestHandler>

You can then call it like this:
http://localhost:8983/solr/select?q=komputer&spellcheck=true

Also don't forget to build the spellcheck dictionary before you use it:
http://localhost:8983/solr/select/?q=*:*&spellcheck=true&spellcheck.build=true

You can force the dictionary to build at each commit by configuring it in the component:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
 <str name="queryAnalyzerFieldType">textSpell</str>
 <lst name="spellchecker">
  <str name="classname">solr.IndexBasedSpellChecker</str>
  <str name="name">default</str>
  <str name="field">name</str>
  <str name="spellcheckIndexDir">./spellchecker1</str>
  <str name="buildOnCommit">true</str>
 </lst>
</searchComponent>

Finally, make sure that your name field is really an indexed field of type textSpell and that it contains enough content to build a good dictionary. In my case, I have a field named spellchecker that is populated from a couple of fields of my index (using copyField instructions in the schema).

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