我将 solr4 与 Autosuggest 一起使用(如此处TermsComponent
所述)我们正在执行一个正则表达式“startsWith”-search,它忽略了大写/小写,整个 searchQuery 看起来像这样:
<solr>/terms
?terms.fl=name
&terms=true
&terms.limit=5
&terms.regex=<term>.*
&terms.regex.flag=case_insensitive
&qt=%2Fterms
让我举几个例子,它会返回什么:
test -> Test Listing; test lowercase
Test -> Test Listing; test lowercase
不幸的是,此解决方案无法处理变音符号、变音符号、重音符号 .. 所以以下方法不起作用:
têst -> Test Listing; test lowercase; Têst áccènt
Test -> Test Listing; test lowercase; Têst áccènt
该字段是string
- 我也尝试过标记化test_en
,但没有成功
<field name="name" type="string" indexed="true" stored="true" required="true" />
对此自动建议启用双向重音搜索的最佳方法是什么?
编辑:AnalyzerSuggester 的更改:
<searchComponent class="solr.SpellCheckComponent" name="autosuggest">
<lst name="spellchecker">
<str name="name">autosuggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingLookupFactory</str>
<str name="storeDir">autosuggest</str>
<str name="buildOnCommit">true</str>
<str name="field">asug</str>
<str name="suggestAnalyzerFieldType">text_asug</str>
<!-- Suggester properties -->
<bool name="exactMatchFirst">true</bool>
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/autosuggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">autosuggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>autosuggest</str>
</arr>
</requestHandler>
.
<fieldType name="text_asug" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.ASCIIFoldingFilterFactory"/>
</analyzer>
</fieldType>