我目前正在使用apache solr,我为搜索文本字段实现了自动完成功能。它适用于字母,但我现在遇到的问题是数字。尽管我的索引中有数字,但数字不会自动完成。有谁知道这种问题?
继承我的schema.xml:
<fieldType name="suggest_de" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.WordDelimiterFilterFactory"
splitOnCaseChange="0" splitOnNumerics="0"
generateWordParts="1" generateNumberParts="0" catenateWords="0"
catenateNumbers="1" catenateAll="0" preserveOriginal="1"/>
<filter class="de.hybris.platform.solrfacetsearch.ysolr.synonyms.HybrisSynonymFilterFactory" ignoreCase="true" synonyms="de" coreName="${solr.core.name}"/>
<filter class="de.hybris.platform.solrfacetsearch.ysolr.stopwords.HybrisStopWordsFilterFactory" ignoreCase="true" lang="de" coreName="${solr.core.name}"/>
<filter class="solr.StopFilterFactory" words="solr/embedded/conf/stopwords_de.txt" ignoreCase="true" />
<filter class="solr.TrimFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
<field name="autosuggest" type="string" indexed="true" stored="true" multiValued="true" />
<field name="autosuggest_de" type="suggest_de" indexed="true" stored="true" multiValued="true" />
<copyField source="autosuggest" dest="autosuggest_de" />
和我的solrconfig.xml:
<requestHandler name="/suggest" class="solr.SearchHandler">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">default</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.collate">true</str>
<str name="mm">100%</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
<searchComponent name="suggest" class="solr.SpellCheckComponent">
<str name="queryAnalyzerFieldType">autosuggest</str>
<lst name="spellchecker">
<str name="name">default</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<str name="field">autosuggest_de</str>
<str name="buildOnOptimize">true</str>
<str name="accuracy">0.35</str>
<str name="characterEncoding">UTF-8</str>
</lst>
<lst name="spellchecker">
<str name="name">de</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<str name="field">autosuggest_de</str>
<str name="buildOnOptimize">true</str>
<str name="accuracy">0.35</str>
<str name="characterEncoding">UTF-8</str>
</lst>
</searchComponent>
正如我所说,字母没有问题,但是在查询中不会返回以数字开头的所有内容。