Solr中的自动完成区分大小写

时间:2015-07-14 12:44:24

标签: solr

我已经实现了一个自动完成组件,其中自动完成变得区分大小写。我添加了以下代码片段并且它区分大小写。如何使这种情况不敏感。

 <searchComponent name="suggest" class="solr.SuggestComponent">
      <lst name="suggester">
        <str name="name">mySuggester</str>
        <str name="lookupImpl">FuzzyLookupFactory</str>      
        <str name="dictionaryImpl">DocumentDictionaryFactory</str>
        <str name="field">name_s</str>
        <str name="weightField">price</str>
        <str name="suggestAnalyzerFieldType">text_general</str>
        <str name="buildOnStartup">false</str>
      </lst>
    </searchComponent>

    <requestHandler name="/suggest" class="solr.SearchHandler" 
                    startup="lazy" >
      <lst name="defaults">
        <str name="suggest">true</str>
        <str name="suggest.count">10</str>
      </lst>
      <arr name="components">
        <str>suggest</str>
      </arr>
  </requestHandler>

1 个答案:

答案 0 :(得分:0)

我通过在schema.xml中添加以下内容来运行此操作。 在schema.xml中

<fieldType name="text_general" class="solr.TextField">
          <analyzer type="index">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
          </analyzer>
          <analyzer type="query">
            <tokenizer class="solr.StandardTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory"/>
          </analyzer>
    </fieldType>