【问题标题】:Solr dictionary based suggester won't suggest on whole phrase基于 Solr 字典的建议器不会建议整个短语
【发布时间】:2014-01-06 13:00:22
【问题描述】:

当我向我的 Suggester 组件输入一个包含多个单词的查询时,我得到了每个单词的单独结果。问题在这里得到了很好的解释:How to have Solr autocomplete on whole phrase when query contains multiple terms?

唯一的区别是,我有一个基于字典文件的建议器,而不是索引字段。上面链接中解释的解决方案以及许多其他解决方案都不起作用

这里是配置:

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
        <str name="name">suggest</str>
        <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
        <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
        <str name="buildOnCommit">true</str>
        <str name="suggestAnalyzerFieldType">text_suggest</str>
        <str name="sourceLocation">suggestionsFull.txt</str>
    </lst>
    <str name="queryAnalyzerFieldType">text_suggest</str>
    <!-- <queryConverter name="queryConverter" class="org.apache.solr.spelling.SuggestQueryConverter"/> -->
</searchComponent>

<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
        <str name="spellcheck">true</str>
        <str name="spellcheck.dictionary">suggest</str>
        <str name="spellcheck.onlyMorePopular">true</str>
        <str name="spellcheck.count">5</str>
        <str name="spellcheck.collate">false</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>

schema.xml

<fieldType name="text_suggest" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.TurkishLowerCaseFilterFactory"/>
        <filter class="solr.TrimFilterFactory"/>
    </analyzer>
</fieldType>

我也用spellcheck.q参数代替q

http://localhost:8983/solr/collection1/suggest?spellcheck.q=bu+bir&wt=json&indent=true

我做错了什么?

【问题讨论】:

    标签: solr autocomplete search-suggestion


    【解决方案1】:

    终于找到了解决办法:

    看起来即使您从文件而不是索引字段构建建议字典,您也必须在 solrconfig.xml 中指定索引字段。因此,在schema.xml 中,从我们已经创建的text_suggest 字段类型创建一个虚拟字段:

    <field name="text_suggest" type="text_suggest" indexed="false" stored="false" />
    

    然后在solrconfig.xml 中将&lt;str name="field"&gt;text_suggest&lt;/str&gt; 行添加到searchComponent

    <searchComponent class="solr.SpellCheckComponent" name="suggest">
           <lst name="spellchecker">
              <str name="name">suggest</str>
              <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
              <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
              <str name="buildOnCommit">true</str>
              <str name="suggestAnalyzerFieldType">text_suggest</str>
              <str name="field">text_suggest</str>
              <str name="sourceLocation">suggestionsFull.txt</str>
           </lst>
        </searchComponent>
    

    重启 solr 就完成了!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多