如何在solr中配置IndexBasedSpellChecker?

时间:2015-08-25 23:00:11

标签: linux apache solr

我正在使用solr 5.2,我想在searchHandler中使用 IndexBasedSpellChecker ,这是我对IndexBasedSpellChecker的搜索组件:

<searchComponent class="solr.SpellCheckComponent" name="spellcheck">
<str name="queryAnalyzerFieldType">text_en_general</str>
  <lst name="spellchecker">
    <str name="name">default</str>
<!--specify a field to use for the suggestions-->
    <str name="field">body-en</str>
    <str name="classname">solr.IndexBasedSpellChecker</str> 
    
  <!-- <str name="distanceMeasure">internal</str> -->
<!--The accuracy setting defines the threshold for a valid suggestion-->
 <!--   <float name="accuracy">0.05</float> -->
<!-- maxEdits defines the number of changes to the term to allow-->
    <int name="maxEdits">2</int> 
<!--defines the minimum number of characters the terms should share-->
   <int name="minPrefix">1</int> 
<!--defines the maximum number of possible matches to review before returning results-->
    <int name="maxInspections">5</int> 
<!--defines how many characters must be in the query before suggestions are provided-->
    <int name="minQueryLength">4</int> 
<!-- sets the maximum threshold for the number of documents a term must appear in before being considered as a suggestion-->
    <float name="maxQueryFrequency">0.01</float> 
<!--sets the minimum number of documents a term must appear in-->
    <float name="thresholdTokenFrequency">.01</float> 

我的问题是,当我想使用精确度时,它会给我这个错误

Caused by: org.apache.solr.common.SolrException: java.lang.Float cannot be cast to java.lang.String

当我评论此设置时,它会给我一个使用distanceMeasure的错误:

 org.apache.solr.common.SolrException:org.apache.solr.common.SolrException: Error loading class 'internal' 

当我为他们两人做好准备时,我无法从我的拼写检查器中得到结果,当我查询一个短语时,它只是拼写检查短语的第一个单词,我应该做什么?

1 个答案:

答案 0 :(得分:0)

我无法看到完整的组件说明,所以我无法确定发生了什么。如果该组件中有多个拼写检查程序,请确保它具有相同的字段名称。

<str name="field">body-en</str>

以下代码适用于我:

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <lst name="spellchecker">
        <str name="name">default</str>
        <str name="field">variations</str>
        <str name="classname">solr.DirectSolrSpellChecker</str>
        <str name="distanceMeasure">internal</str>
        <float name="accuracy">0.5</float>
        <int name="maxEdits">2</int>
        <int name="minPrefix">1</int>
        <int name="maxInspections">5</int>
        <int name="minQueryLength">4</int>
        <float name="maxQueryFrequency">0.01</float>
        <float name="thresholdTokenFrequency">.01</float>
    </lst>
</searchComponent>

使用以下请求处理程序代码段:

<str name="spellcheck.dictionary">default</str>
<str name="spellcheck">true</str>
<str name="spellcheck.count">3</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.extendedResults">true</str>
<str name="spellcheck.collate">true</str>

希望它有所帮助!