本文介绍了Solr的建议 - 如何定义Solr的建议不区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的建议(拼写检查)将返回区分大小写的答案。
(我用它来自动完成 - 狗与狗返回不同的短语)\\
我的建议定义如下 -
在solrconfig -
<的SearchComponent类=solr.SpellCheckComponentNAME =建议>
< LST NAME =拼写检查>
< STR名=名与GT;建议< / STR>
< STR NAME =类名> org.apache.solr.spelling.suggest.Suggester< / STR>
< STR NAME =lookupImpl> org.apache.solr.spelling.suggest.tst.TSTLookup< / STR>
< STR NAME =场>建议< / STR> <! - 索引字段从得到的建议 - >
<浮动NAME =门槛> 0.005 LT; /浮动>
< STR NAME =buildOnCommit>真< / STR>
<! - < STR NAME =sourceLocation>美式英语和LT; / STR> - >
< / LST>
< /&的SearchComponent GT;
< requestHandler类=org.apache.solr.handler.component.SearchHandlerNAME =/提示>
< LST NAME =默认>
< STR NAME =拼写检查>真< / STR>
< STR NAME =spellcheck.dictionary>建议< / STR>
< STR NAME =spellcheck.onlyMorePopular>真< / STR>
< STR NAME =spellcheck.count> 5℃/ STR>
< STR NAME =spellcheck.collate>真< / STR>
< / LST>
< ARR NAME =组件>
< STR>建议< / STR>
< / ARR>
< / requestHandler>
在架构
<字段名=建议TYPE =phrase_suggest收录=真正的存储=真要求=假多值=真/>
和
< copyField源=姓名目标=建议/>
和
<字段类型名称=phrase_suggest级=solr.TextField>
<分析仪和GT;
< tokenizer类=solr.KeywordTokenizerFactory/>
<过滤器类=solr.PatternReplaceFilterFactory
模式=([^ \\ p {L〕\\ p {M-} \\ p {N} \\ p {铯}] * [\\ p {L〕\\ p {M-} \\ p {N} \\ p {铯} \\ _] + :) |([^ \\ p {L〕\\ p {M-} \\ p {N} \\ p {}铯])+
更换=替换=所有/>
<过滤器类=solr.LowerCaseFilterFactory/>
<过滤器类=solr.TrimFilterFactory/>
< /分析仪>
< /字段类型>
解决方案
尝试改变它们添加到字段类型
过滤器工厂的订单。此外,地方 LowerCaseFilterFactory
在列表的顶端。
Shishir
My suggest (spellchecker) is returning case sensitive answers.(I use it to autocomplete - dog and Dog return different phrases)\
my suggest is defined as follows -in solrconfig -
<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.tst.TSTLookup</str>
<str name="field">suggest</str> <!-- the indexed field to derive suggestions from -->
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
<!--<str name="sourceLocation">american-english</str>-->
</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">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
in schema
<field name="suggest" type="phrase_suggest" indexed="true" stored="true" required="false" multiValued="true"/>
and
<copyField source="Name" dest="suggest"/>
and
<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>
</fieldtype>
解决方案
Try to change the order of filter factories which are added into the fieldType
. Also, place LowerCaseFilterFactory
at the top of the list.
Shishir
这篇关于Solr的建议 - 如何定义Solr的建议不区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!