SolrSpellChecker返回索引

时间:2017-05-11 08:13:51

标签: solr lucene spell-checking

我正在尝试使用Solr进行拼写检查。我可以在拼写错误的单词时获得建议。 例如:输入的字词(错误):维护 我正在" 维护"作为建议,但如果我查询维护,它会提供维护作为建议,即使索引中存在维护

solrConfig:

 <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">text_general</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">spell_text</str>
<str name="classname">solr.DirectSolrSpellChecker</str>
<str name="distanceMeasure">org.apache.lucene.search.spell.LevensteinDistance</str>
<float name="accuracy">0.5</float>
 <str name="buildOnCommit">true</str>  

</lst>


    <lst name="spellchecker">
      <str name="name">spellcheck_en</str>
      <str name="field">spell_text</str>
      <str name="classname">solr.IndexBasedSpellChecker</str>
      <str name="spellcheckIndexDir">./spellchecker</str>

      <str name="distanceMeasure">org.apache.lucene.search.spell.LevensteinDistance</str>

      <str name="accuracy">0.5</str>

      <int name="maxEdits">1</int>

      <int name="minPrefix">1</int>

      <int name="maxInspections">5</int>

      <int name="minQueryLength">4</int>

      <float name="maxQueryFrequency">.01</float>

        <float name="thresholdTokenFrequency">0.001</float>

           <str name="buildOnCommit">true</str>

    </lst>

<lst name="spellchecker">
<str name="name">wordbreak</str>
<str name="classname">solr.WordBreakSolrSpellChecker</str>
<str name="field">spell_text</str>
<str name="combineWords">true</str>
<str name="breakWords">true</str>
<int name="maxChanges">5</int>
    <int name="minBreakLength">5</int>
         <str name="buildOnCommit">true</str>

</lst>

</searchComponent>

<requestHandler name="/spell" class="org.apache.solr.handler.component.SearchHandler">
  <lst name="defaults">
        <str name="spellcheck.dictionary">default</str>
        <str name="spellcheck.dictionary">spellcheck_en</str>
    <str name="spellcheck.dictionary">wordbreak</str>
    <str name="spellcheck">true</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.extendedResults">true</str>
        <str name="spellcheck.count">5</str>
        <str name="spellcheck.alternativeTermCount">2</str>
        <str name="spellcheck.maxResultsForSuggest">100</str>
        <str name="spellcheck.collate">true</str>
        <str name="spellcheck.collateExtendedResults">true</str>
        <str name="spellcheck.maxCollationTries">5</str>
        <str name="spellcheck.maxCollations">1</str>
         <str name="spellcheck">true</str>

  </lst>
  <arr name="last-components">
    <str>spellcheck</str>
  </arr>
</requestHandler>

如何忽略索引中存在的查询字词的建议。

0 个答案:

没有答案