Apache Solr(版本4.10)无法提供拼写检查建议

时间:2018-07-09 20:37:07

标签: solr

这令人沮丧,我不确定是什么引起了问题。我已经阅读了几篇文档,没有真正的答案。我在三个节点上运行了SolrCloud,下面给出了我的Solr配置。由于某些原因,如果拼写错误,它将无法提供拼写建议。当找不到给定错误拼写的匹配项时,它可以告诉正确的拼写为“ false”,但是它不能建议正确的拼写。有什么想法吗?

schema.xml:

<field name="mfr_spell" type="mfr_spell_analyzer" indexed="true" stored="true" omitNorms="true" multiValued="false"/>
<copyField source="mfr" dest="mfr_spell"/>

<fieldType name="mfr_spell_analyzer" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
  </analyzer>
</fieldType>

solrconfig.xml:

<searchComponent name="mfrspellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">mfr_spell_analyzer</str>

<lst name="spellchecker">
  <str name="name">mfr_default</str>
  <str name="field">mfr_spell</str>
  <str name="classname">solr.DirectSolrSpellChecker</str>
  <!-- the spellcheck distance measure used, the default is the internal levenshtein -->
  <str name="distanceMeasure">internal</str>
  <!-- minimum accuracy needed to be considered a valid spellcheck suggestion -->
  <float name="accuracy">0.001</float>
  <!-- the maximum #edits we consider when enumerating terms: can be 1 or 2 -->
  <int name="maxEdits">2</int>
  <!-- the minimum shared prefix when enumerating terms -->
  <int name="minPrefix">1</int>
  <!-- maximum number of inspections per result. -->
  <int name="maxInspections">5</int>
  <!-- minimum length of a query term to be considered for correction -->
  <int name="minQueryLength">4</int>
  <!-- maximum threshold of documents a query term can appear to be considered for correction -->
  <float name="maxQueryFrequency">0.01</float>
  <!-- uncomment this to require suggestions to occur in 1% of the documents-->
  <float name="thresholdTokenFrequency">0.01</float>
</lst>
</searchComponent>

<requestHandler name="/spellmfr" class="solr.SearchHandler">
 <lst name="defaults">
   <str name="echoParams">explicit</str>
   <str name="wt">xml</str>
   <str name="indent">true</str>
   <str name="df">mfr_spell</str>
   <str name="spellcheck.dictionary">mfr_default</str>
   <str name="spellcheck">on</str>
   <str name="spellcheck.extendedResults">true</str>
   <str name="spellcheck.count">10</str>
   <str name="spellcheck.alternativeTermCount">1</str>
   <str name="spellcheck.maxResultsForSuggest">0</str>
 </lst>
 <arr name="last-components">
     <str>mfrspellcheck</str>
 </arr>
</requestHandler>

0 个答案:

没有答案