1
我試圖設置建議組件,但我沒有得到我期望的結果。我希望我能回覆短語,但我收回單詞,有些甚至不存在。數據如下所示:Solr建議不返回多個條款
Fullerton, CA
Fulton, NY
Fultondale, AL
Fulton County, GA
我的架構文件看起來像:
<fieldType name="text_general" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<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樣子:
<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">Location</str>
</lst>
<!-- specify a fieldtype using keywordtokenizer + lowercase + cleanup -->
<str name="queryAnalyzerFieldType">phrase_suggest</str>
</searchComponent>
<queryConverter name="queryConverter" class="org.apache.solr.spelling.SuggestQueryConverter"/>
<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.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
結果是這樣的:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="ful">
<int name="numFound">5</int>
<int name="startOffset">0</int>
<int name="endOffset">3</int>
<arr name="suggestion">
<str>fuld</str>
<str>full</str>
<str>fuller</str>
<str>fulton</str>
<str>fultondale</str>
</arr>
</lst>
<str name="collation">fuld</str>
</lst>
</lst>
</response>
任何幫助將不勝感激。
你設法解決它? – JHS