我已经使用AnalyzingInfixLookupFactory
配置了solr(7.5.0)建议者组件,并且工作正常。
但是,我想获取除建议字段(建议从中生成建议)以外的字段值,包括建议短语。例如,我在Solr文档的“ nick_name”字段中将“ Taylor Swift”存储为“ full_name”和“ T-Swizz”。现在,如果我想对“ Swiz” 提出建议,它应该返回术语“ T-Swizz” 和另一个术语“ Taylor Swift” (存储在同一文档的另一个字段中)。
这是Solr中每个文档的字段:
<field name="full_name" type="textToken" indexed="true"
stored="true" multiValued="true" />
<field name="nick_name" type="textToken" indexed="true" stored="true"
multiValued="true" />
<fieldType class="solr.TextField" name="textToken"
positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory" />
<filter class="solr.StandardFilterFactory" />
<filter class="solr.LowerCaseFilterFactory" />
</analyzer>
</fieldType>
这是我的搜索组件:
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">mySuggester1</str>
<str name="lookupImpl">AnalyzingInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">nick_name</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">true</str>
<str name="suggestAnalyzerFieldType">text</str>
<str name="queryAnalyzerFieldType">text_suggest</str>
</lst>
</searchComponent>
<fieldtype name="text_suggest" class="solr.TextField">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.TrimFilterFactory"/>
</analyzer>
</fieldtype>
这是我的请求处理程序:
<requestHandler name="/suggest" class="solr.SearchHandler"
startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
这是我在Solr中的文件之一:
{
"full_name":["Taylor Swift"],
"nick_name":["T-Swizz"],
"id":"bf47cb69-b132-46b2-b3f3-7163f07ffdca",
"_version_":1615396924172533760
}
有没有办法做到这一点,或者我做错了什么?