我在Solr
中创建了2个 2分片的节点。我正在做拼写纠正技术。我希望在频率的基础上排序 查询(abple)的建议。通过默认,得分(Levenshtein距离)排序。
我在 solrconfig.xml 的 solr.SpellCheckComponent 中添加了<str name="comparatorClass">freq</str>
。但仍然是不工作。
当前建议按分数排序(不需要):
"suggestion":[{
"word":"apple",
"freq":23},
{
"word":"ample",
"freq":5},
{
"word":"abele",
"freq":3},
{
"word":"able",
"freq":176}}]
需要建议按频率排序(必填):
"suggestion":[{
"word":"able",
"freq":176}},
{
"word":"apple",
"freq":23},
{
"word":"ample",
"freq":5},
{
"word":"abele",
"freq":3}}]
配置文件:
solrconfig.xml中:
<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">textSpellCi</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">gram_ci</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">0</int>
<int name="maxInspections">5</int>
<int name="minQueryLength">2</int>
<float name="maxQueryFrequency">0.9</float>
<str name="comparatorClass">freq</str>
</lst>
</searchComponent>
<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">gram_ci</str>
<str name="spellcheck.dictionary">default</str>
<str name="spellcheck">on</str>
<str name="spellcheck.extendedResults">true</str>
<str name="spellcheck.count">25</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.maxResultsForSuggest">100000000</str>
<str name="spellcheck.alternativeTermCount">25</str>
<str name="spellcheck.collate">true</str>
<str name="spellcheck.maxCollations">50</str>
<str name="spellcheck.maxCollationTries">50</str>
<str name="spellcheck.collateExtendedResults">true</str>
</lst>
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>
Schema.xml的:
<field name="gram_ci" type="textSpellCi" indexed="true" stored="true" multiValued="false"/>
</fieldType><fieldType name="textSpellCi" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ShingleFilterFactory" maxShingleSize="5" minShingleSize="2" outputUnigrams="true"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ShingleFilterFactory" maxShingleSize="5" minShingleSize="2" outputUnigrams="true"/>
</analyzer>
</fieldType>
答案 0 :(得分:0)
将此参数添加到搜索处理程序后尝试:
<str name="spellcheck.onlyMorePopular">true</str>