【发布时间】:2015-10-14 18:04:18
【问题描述】:
我正在像谷歌一样创建建议。现在,当我写“do”时,solr 返回“dog”、“doll”,它只返回模式字段上的一个单词。 我想要的是如果它返回整个字段,例如“doggy blah blah”、“dog store”等,那就太好了。 这是我的 schema.xml
<field name = "companyDisplayName" type = "text_auto" multiValued="false" indexed = "true" stored = "false" />
和我的架构字段类型配置:
<fieldType name="text_auto" class="solr.TextField" positionIncrementGap="100" ><analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" maxGramSize="30" minGramSize="1"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
这是我的 solrconfig.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.fst.AnalyzingInfixLookupFactory</str>
<str name="buildOnCommit">true</str>
<str name="suggestAnalyzerFieldType">text_auto</str>
<str name="field">companyDisplayName</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">false</str>
<str name="echoParams">explicit</str>
<str name="defType">edismax</str>
<str name="rows">10</str>
<str name="fl">companyDisplayName</str>
<str name="qf">companyDisplayName^30</str>
<str name="pf">companyDisplayName^50.0</str>
<str name="group">true</str>
<str name="group.field">companyDisplayName</str>
<str name="sort">score desc</str>
<str name="group.sort">score desc</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
和我的查询:
http://localhost:8983/solr/vw_search_company_with_buildings/suggest?spellcheck.q=hunn
【问题讨论】: