我在solr中实现了一个自动完成功能。结果总是完全小写的,我希望它们有原来的大小写。对于查询“ Alexandria ”我得到的结果“ Alexandria ”,它应该是“ Alexandria ”
托管架构:
<field name="suggest_field" type="text_shingle" indexed="true" stored="false" multiValued="true"/>
...
<copyField source="_text_" dest="suggest_field"/>
...
<fieldType name="text_shingle" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" format="snowball" />
<!--filter class="solr.EdgeNGramFilterFactory" minGramSize="4" maxGramSize="15"/-->
<!--filter class="solr.ShingleFilterFactory" minShingleSize="2" maxShingleSize="4" outputUnigrams="false" outputUnigramsIfNoShingles="true" fillerToken=""/-->
<filter class="solr.TrimFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_suggest" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.TrimFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
solrconfig.xml
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">default</str>
<str name="lookupImpl">BlendedInfixLookupFactory</str>
<str name="dictionaryImpl">HighFrequencyDictionaryFactory</str>
<str name="field">suggest_field</str>
<str name="suggestAnalyzerFieldType">text_suggest</str>
<str name="minPrefixChars">2</str>
<str name="exactMatchFirst">true</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">true</str>
<str name="highlight">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>
<str name="suggest.dictionary">default</str>
<str name="echoParams">explicit</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
当我删除LowerCaseFilterFactory时,我在结果中得到了所需的原始大小写,但是查询是区分大小写的。对于“ Alexandria ”,我得到了0个结果。
1条答案
按热度按时间njthzxwz1#
只在索引分析器中删除LowerCaseFilterFactory似乎可以达到这个目的。