本文主要是介绍Solr6+Suggest(提示),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在搭建Solr服务器的基础上(http://blog.csdn.net/u010379996/article/details/51790743)
1. 配置manage-schema
添加:<fieldType name="text_spell" 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>
<field name="suggestion" type="textComplex" indexed="true" stored="true" termVectors="true" multiValued="true" />
<copyField source="content_test" dest="suggestion" />
//content_test为需要suggest的字段,solr的field
2. 配置solrconfig.xml
添加:
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<str name="queryAnalyzerFieldType">text_spell</str>
<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">suggestion</str>
<!-- the indexed field to derive suggestions from -->
<float name="threshold">0.0001</float>
<str name="spellcheckIndexDir">spellchecker</str>
<str name="comparatorClass">freq</str>
<str name="buildOnOptimize">true</str>
<!--<str name="buildOnCommit">true</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.extendedResults">false</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
<queryConverter name="phraseQueryConverter" class="org.apache.solr.spelling.SpellingQueryConverter"/>
//原配置文件有,则注掉
3. 重新创建索引
这篇关于Solr6+Suggest(提示)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!