gpt4 book ai didi

Solr 建议 - 如何将 solr 建议定义为不区分大小写

转载 作者:行者123 更新时间:2023-12-01 05:02:36 25 4
gpt4 key购买 nike

我的建议(拼写检查)正在返回区分大小写的答案。
(我用它来自动完成 - dog 和 Dog 返回不同的短语)\

我的建议定义如下 -
在 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>

在模式中
<field name="suggest" type="phrase_suggest" indexed="true" stored="true" required="false" multiValued="true"/>  


<copyField source="Name" dest="suggest"/>


<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>

最佳答案

为此,您需要将字段类型添加到 solrconfig.xml 中的搜索组件声明中
在这种情况下,“phrase_suggestion”但匹配您在 schema.xml 中创建的具有小写过滤器工厂声明的任何字段类型。

<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>

<!-- THIS IS THE LINE TO ADD -->
<str name="suggestAnalyzerFieldType">phrase_suggest</str>

</lst>
</searchComponent>

关于Solr 建议 - 如何将 solr 建议定义为不区分大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18685979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com