我已经使用IndexBasedSpellChecker和一个包含国家/地区名称的核心配置了Solr拼写检查组件:

<searchComponent name="indexBasedSpellCheck" class="solr.SpellCheckComponent">
    <lst name="spellchecker">
      <str name="name">indexBasedSpellCheck</str>
      <str name="classname">solr.IndexBasedSpellChecker</str>
      <str name="spellcheckIndexDir">./indexspellchecker</str>
      <str name="field">name</str>
      <str name="buildOnCommit">true</str>
      <str name="distanceMeasure">org.apache.lucene.search.spell.LevensteinDistance</str>
      <str name="accuracy">0.5</str>
    </lst>
  </searchComponent>


还有用于拼写检查的请求处理程序:

<requestHandler name="/index-spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="spellcheck.dictionary">idxBasedSpellCheck</str>
      <str name="spellcheck">on</str>
      <str name="spellcheck.extendedResults">true</str>
      <str name="spellcheck.count">10</str>
      <str name="spellcheck.alternativeTermCount">5</str>
      <str name="spellcheck.maxResultsForSuggest">5</str>
      <str name="spellcheck.collate">true</str>
      <str name="spellcheck.collateExtendedResults">true</str>
      <str name="spellcheck.maxCollationTries">10</str>
      <str name="spellcheck.maxCollations">5</str>
    </lst>
    <arr name="last-components">
      <str>indexBasedSpellCheck</str>
    </arr>
  </requestHandler>


当我要求时:

curl 'http://localhost:8983/solr/mycore/index-spell?indent=on&spellcheck.q=tanaz&wt=json&spellcheck.collate=true'

我得到以下建议的结果:

 "spellcheck":{
    "suggestions":[
      "tanaz",{
        "numFound":3,
        "startOffset":0,
        "endOffset":5,
        "origFreq":0,
        "suggestion":[{
            "word":"canada",
            "freq":1},
          {
            "word":"panama",
            "freq":1},
          {
            "word":"tanzania",
            "freq":1}]}],
    "correctlySpelled":false,
    "collations":[]}


为什么我的归类为空?我的请求中有spellcheck.collat​​e = true。

最佳答案

我认为您在请求中缺少df(默认字段)参数。
  在您的请求中添加df=name

http://localhost:8983/solr/mycore/index-spell?indent=on&spellcheck.q=tanaz&wt=json&spellcheck.collate=true&df=name

您还可以在默认的请求处理程序中配置它,因此不需要在请求中发送它。

<requestHandler name="/index-spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
       ...
      <str name="df">name</str>
       ...
    </lst>
    <arr name="last-components">
      <str>idxBasedSpellCheck</str>
    </arr>
  </requestHandler>

关于java - 为什么排序规则结果在Solr拼写检查中为空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46968819/

10-13 05:26