建议不使用比较器按频率排序Freq =freq(不工作)

gstyhher  于 2022-11-05  发布在  Solr
关注(0)|答案(2)|浏览(131)

我已经在Solr中创建了2个节点,有2个碎片。我正在使用拼写纠正技术。我想排序**********查询(abple)建议,基于频率默认,它是排序*基于分数(Levenshtein距离)。
我在solrconfig.xmlsolr.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}}]

配置文件:
解决方案配置.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>

架构.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>
bxgwgixi

bxgwgixi1#

我也遇到过类似的问题,但我做出了你提到的改变:

<str name="comparatorClass">freq</str>

您可能尚未重新启动solr示例。请先尝试重新启动。

92vpleto

92vpleto2#

请在将此参数添加到搜索处理程序后尝试:
<str name="spellcheck.onlyMorePopular">true</str>

相关问题