AnalyzingInfixSuggester给出了一个建议

时间:2014-07-07 13:17:38

标签: solr lucene autosuggest

对于为AnalyzingSuggester提供多个建议的相同字典,它只为AnalyticsInfixSuggester提供一个单一建议

以下是我的配置:

<!-- AnalyzingInfixLookup suggest component (default)-->
<searchComponent class="solr.SpellCheckComponent" name="infix_suggest_analyzing">
<lst name="spellchecker">
  <str name="name">infix_suggest_analyzing</str>
  <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
  <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
  <str name="storeDir">infix_suggest_analyzing</str>
  <str name="buildOnCommit">false</str>

  <!-- Suggester properties -->
  <str name="suggestAnalyzerFieldType">text</str>
  <str name="field">debug_field</str>
  <str name="sourceLocation">${solr.solr.home}/${solr.core.name}/dictionaries/dictionary.txt</str>
</lst>

  <!-- specify a fieldtype using keywordtokenizer + lowercase + cleanup -->
  <str name="queryAnalyzerFieldType">debug_type</str>
</searchComponent>

<!--  Infix analyzing handler (default) -->
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/infix_suggest_analyzing">
<lst name="defaults">
  <str name="spellcheck">true</str>
  <str name="spellcheck.dictionary">infix_suggest_analyzing</str>
  <!-- NOTE: if this is false, results are alpha-ordered, not by weight! -->
  <str name="spellcheck.onlyMorePopular">true</str>
</lst>
<arr name="components">
  <str>infix_suggest_analyzing</str>
</arr>
</requestHandler>

我的架构:

<fieldtype name="debug_type" class="solr.TextField" positionIncrementGap="1000">
  <analyzer>
    <tokenizer class="solr.KeywordTokenizerFactory" />
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
 </fieldtype>


<!-- basic text field -->
<fieldtype name="text" class="solr.TextField">
  <analyzer>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldtype>

<fieldtype name="phrase_suggest" class="solr.TextField">
<analyzer>
  <tokenizer class="solr.KeywordTokenizerFactory"/>
  <filter class="solr.PatternReplaceFilterFactory"
          pattern="([^\p{L}\p{M}\p{N}\p{Cs}]*[\p{L}\p{M}\p{N}\p{Cs}\_]+:)|([^\p{L}\p{M}\p{N}\p{Cs}])+"
          replacement=" " replace="all"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.TrimFilterFactory"/>
</analyzer>

知道为什么只建议一个建议吗?我使用solr 4.6,字典的格式为。这与AnalyzingSuggester完美配合。

1 个答案:

答案 0 :(得分:1)

我不确定它是否回答了你的问题,但这是我的工作实例。

我正在使用Solr 4.6.0。 我的词典基于string字段:suggest_field。归档类型suggest_string仅由建议者使用,请注意它使用

<tokenizer class="solr.StandardTokenizerFactory" />

中缀功能不适用于solr.KeywordTokenizerFactory

schema.xml中:

<field name="suggest_field" type="string" indexed="true" stored="true" multiValued="true"/>

<fieldType name="suggest_string" class="solr.TextField" sortMissingLast="true" omitNorms="true">
    <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>           
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.ASCIIFoldingFilterFactory"/>
    </analyzer>
</fieldType>

solrconfig.xml中:

<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="field">suggest_field</str>

        <!-- Minimum frequency of terms to consider when building the dictionary
        0 == all terms -->
        <float name="threshold">0.0</float> 
        <str name="buildOnCommit">true</str>
        <str name="suggestAnalyzerFieldType">suggest_string</str>

        <bool name="exactMatchFirst">true</bool>
    </lst>
</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">10</str>
        <str name="spellcheck.collate">false</str>
    </lst>
    <arr name="components">
        <str>suggest</str>
    </arr>
</requestHandler>