How to sort SOLR spellCheck suggestions NOT by frequency?

被刻印的时光 ゝ 提交于 2019-12-02 08:57:46
Patricia Gorla

By default, spellcheck results are returned based on the Levenshtein string distance formula and then frequency, or the frequency and then score.

You can specify your own sorting method by writing a custom comparator that implements Comparator. Then, provide the name of that method to the field comparatorClass in your solrconfig.xml.

<lst name="spellchecker">
  <str name="name">freq</str>
  <str name="field">lowerfilt</str>
  <str name="spellcheckIndexDir">spellcheckerFreq</str>
  <!-- comparatorClass be one of:
     1. score (default)
     2. freq (Frequency first, then score)
     3. A fully qualified class name
   -->
  <str name="comparatorClass">my.custom.ComparatorClass</str>
  <str name="buildOnCommit">true</str>
</lst>

A couple more suggestions:

  • The field spellcheck.onlyMorePopular doesn't affect sort ordering. This field checks the query results for each suggestion, and displays only the suggestions with the most query results, even if the correct suggestion exists. Use with caution.

  • Make sure to remove stopwords such as 'the', 'that', etc, by passing in your data through the StopFilterFactory on both the index and query side of your requestHandler.

See: http://wiki.apache.org/solr/SpellCheckComponent for more information.

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