使用标记化的solr autosuggestion

时间:2017-07-31 13:24:32

标签: solr

我正在尝试使用标记化进行自动提示。如果我提供' solr',我应该得到' Apache Solr'太。以下配置提供的结果为“Apache solr'如果我提供' apache'。我需要一个标记化的通配符搜索。

管理型模式

<fieldType name="custom_text" class="solr.TextField" positionIncrementGap="100" multiValued="true">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>        
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

<field name="content" type="custom_text" multiValued="false" indexed="true" required="false" stored="true"/>

应用请求处理程序如下:

<searchComponent name="customsuggest" class="solr.SuggestComponent">
    <lst name="suggester">
        <str name="name">customsuggester-content</str>
        <str name="lookupImpl">FuzzyLookupFactory</str>
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">content</str>
        <str name="weightField">price</str>
        <str name="suggestAnalyzerFieldType">custom_text</str>
        <str name="buildOnStartup">false</str>
    </lst>
</searchComponen>
<requestHandler name="/customsuggest" class="solr.SearchHandler"
      startup="lazy">
    <lst name="defaults">
        <str name="suggest">true</str>
        <str name="suggest.count">10</str>
    </lst>
    <arr name="components">
        <str>customsuggest</str>
    </arr>
</requestHandler>

当我尝试使用以下网址时,没有结果从中获取:

http://host:port/solr/collection-name/customsuggest?suggest=true&suggest.build=true&suggest.dictionary=customsuggester-content&indent=on&wt=json&suggest.q=solr

当我尝试使用以下网址时,我会得到结果:

http://host:port/solr/collection-name/customsuggest?suggest=true&suggest.build=true&suggest.dictionary=customsuggester-content&indent=on&wt=json&suggest.q=apache

1 个答案:

答案 0 :(得分:1)

尝试使用&#34; AnalyzingInfixLookupFactory&#34; lookupImpl。它提供的建议包含您在建议内容中任何位置的令牌。

<searchComponent name="customsuggest" class="solr.SuggestComponent">
<lst name="suggester">
    <str name="name">customsuggester-content</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">content</str>
    <str name="suggestAnalyzerFieldType">custom_text</str>
    <str name="buildOnStartup">false</str>
</lst>

您可以在Solr Suggester Overview

找到所有可用的查找实施