我正在使用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'
当我同时出现时,我无法从我的拼写检查器得到结果,当我查询一个短语时,它只是拼写检查短语的第一个单词,我应该怎么做?
最佳答案
我看不到完整的组件描述,所以我不能确定发生了什么。如果该组件中有多个拼写检查器,请确保它具有相同的字段名。
<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>
希望有帮助!
关于linux - 如何在Solr中配置IndexBasedSpellChecker?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32215468/