如何配置Solr建议者?

时间:2015-02-11 13:17:31

标签: java solr autocomplete autosuggest search-suggestion

solrconfig.xml

添加了一个搜索组件,如下所示

<searchComponent class="solr.SuggestComponent" name="suggest">
  <lst name="suggester">
    <str name="name">suggest</str>
    <str name="lookupImpl">FSTLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">suggestions</str> //indexed field of type textspell
    <str name="weightField">price</str><!-- 
    <float name="threshold">0.005</float> -->
    <str name="buildOnCommit">true</str>
    <str name="suggestAnalyzerFieldType">string</str>
  </lst>
</searchComponent>

然后添加了一个请求处理程序来处理如下建议,

<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
    <str name="suggest">true</str>
    <str name="suggest.count">10</str>
    <str name="suggest.dictionary">suggest</str>
</lst>
<arr name="components">
    <str>suggest</str>
</arr></requestHandler>

schema.xml 中添加了名为field的{​​{1}},

suggestions
<field name="suggestions" type="textSpell" indexed="true" stored="false" multiValued="true" /> field type

定义为,

textSpell

在我查询时<fieldType class="solr.TextField" name="textSpell" positionIncrementGap="100"> <analyzer> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StandardFilterFactory"/> <filter class="solr.LowerCaseFilterFactory"/> </analyzer></fieldType> restarting特定reindexing名为core之后,

libshelf

结果是,

http://localhost:8983/solr/libshelf/suggest?suggest=true&suggest.build=true&suggest.dictionary=suggest&wt=json&suggest.q=c

自提法的{ "responseHeader": { "status": 0, "QTime": 32 }, "command": "build", "suggest": { "suggest": { "c": { "numFound": 0, "suggestions": [] } } }} 基于dicionaries字段indexedpagecontent以来已创建了两个pagetitlecopyfields seed如下,

suggesters

如何解决此问题?

0 个答案:

没有答案