Solr拼写检查器没有返回任何结果

时间:2012-06-19 22:23:13

标签: solr lucene spell-checking

我正在开发一个需要我第一次使用Solr的应用程序。我设置了它,索引正确的数据,并按照我的意愿查询,但我不能似乎让拼写检查组件正常工作。无论我查询什么,拼写检查器都不会返回任何建议。我已经包含了solrconfig和schema.xml的相关部分。

schema.xml中

<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
  <analyzer type="index">
    <charFilter class="solr.HTMLStripCharFilterFactory"/>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StandardFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true"  expand="true"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StandardFilterFactory"/>
  </analyzer>
</fieldType>

<!-- CUT -->

<field name="spell" type="textSpell" indexed="true" stored="true" />

solrconfig.xml中

<requestHandler name="/select" class="solr.SearchHandler">
   <lst name="defaults">
     <str name="defType">edismax</str>
     <str name="spellcheck.dictionary">default</str>
     <str name="spellcheck.onlyMorePopular">false</str>
     <!-- <str name="spellcheck.extendedResults">false</str> -->
     <str name="spellcheck.count">3</str>

    <str name="qf">
      frontlist_flapcopy^0.5 title^2.0  subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
    </str>
    <str name="pf">
      frontlist_flapcopy^0.5 title^2.0  subtitle^1.0 series^1.5 author^3.0 frontlist_ean^6.0
    </str>
    <str name="fl">
      title,subtitle,series,author,eans,formats,prices,frontlist_ean,onsaledate,imprint,frontlist_flapcopy
    </str>
    <str name="mm">
      2&lt;-1 5&lt;-2 6&lt;90%
    </str>
    <int name="ps">100</int>
    <bool name="hl">true</bool>
    <str name="q.alt">*:*</str>
    <str name="hl.fl">title,subtitle,series,author,frontlist_flapcopy</str>
    <str name="f.title.hl.fragsize">0</str>
    <str name="f.title.hl.alternateField">title</str>
    <str name="f.subtitle.hl.fragsize">0</str>
    <str name="f.subtitle.hl.alternateField">url</str>
    <str name="f.series.hl.fragsize">0</str>
    <str name="f.series.hl.alternateField">url</str>
    <str name="f.author.hl.fragsize">0</str>
    <str name="f.author.hl.alternateField">url</str>
    <str name="f.frontlist_flapcopy.hl.fragsize">0</str>
    <str name="f.frontlist_flapcopy.hl.alternateField">url</str>

    <str name="echoParams">explicit</str>
    <float name="accuracy">0.7</float>
   </lst>

   <lst name="appends">
       <str name="fq">forsaleinusa:true</str>
   </lst>
   <arr name="last-components">
      <str>spellcheck</str>
   </arr>
</requestHandler>

<!-- CUT -->

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
  <lst name="spellchecker">
    <str name="name">default</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="field">spell</str>
    <str name="spellcheckIndexDir">/path/to/my/spell/index</str>
    <str name="accuracy">0.7</str>
    <float name="thresholdTokenFrequency">.0001</float>
  </lst>

  <lst name="spellchecker">
    <str name="name">jarowinkler</str>
    <str name="classname">solr.IndexBasedSpellChecker</str>
    <str name="field">spell</str>
    <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
    <str name="spellcheckIndexDir">/path/to/my/spell/index</str>
  </lst>

  <str name="queryAnalyzerFieldType">textSpell</str>
</searchComponent>

当我转到http://localhost:8983/solr/select/?q=query&spellcheck.build=true然后查看/ path / to / my / spell / index中生成的文件时,有一个segments.gen和一个segments_1,两者都只包含几个字节的二进制文件数据。然后,当我输入查询并将&spellcheck=true附加到查询字符串时,无论我的查询是什么,我都会收到 no 建议:

<lst name="spellcheck">
  <lst name="suggestions"/>
</lst>

知道这里发生了什么吗?

2 个答案:

答案 0 :(得分:3)

我有一个非常类似的问题,我无法解决。有人在我的问题上发布了一个可以帮助你的详细答案:

solr suggester not returning any results

答案 1 :(得分:2)

我不久前最终解决了这个问题,但对我的回忆,问题是我使用多个<copyField/>指令将数据复制到“spell”字段,但我没有设置{{1在那个领域。当我将拼写检查字段变为多值时,它就像一个魅力!