我定义了一个这样的建议组件:
<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">autosuggest_general</str>
<float name="threshold">0.005</float>
<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.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
和autosuggest_general
字段如下:
<field name="autosuggest_general" type="autosuggest_type" indexed="true" stored="true" multiValued="true" />
<fieldType name="autosuggest_type" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<charFilter class="solr.HTMLStripCharFilterFactory"/>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
建议器组件不返回任何非英语单词的命中。
我想为wordMarcos
获取自动完成
因此,当我调用http://localhost:8983/solr/mycore/suggest?q=mar
时,我得到以下响应:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions"/>
</lst>
</response>
常规搜索返回10次点击:http://localhost:8983/solr/mycore/select?q=autosuggest_general:marcos
对于de
我得到以下响应:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="de">
<int name="numFound">3</int>
<int name="startOffset">0</int>
<int name="endOffset">2</int>
<arr name="suggestion">
<str>design</str>
<str>developer</str>
<str>development</str>
</arr>
</lst>
<str name="collation">design</str>
</lst>
</lst>
</response>
design
、开发者
和开发
都很好,但是我在建议中没有得到dejan
,这个词确实存在于autosuggest_general
字段中。
http://localhost:8983/solr/mycore/select?q=autosuggest_general: dejan
返回
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
<lst name="params">
<str name="q">autosuggest_general:dejan</str>
</lst>
</lst>
<result name="response" numFound="7" start="0">
...
</result>
</response>
我正在使用Solr 4.1
任何帮助将不胜感激!
这可能是一个问题:
<float name="threshold">0.005</float>
https://wiki.apache.org/solr/Suggester说:
阈值-阈值是[0…1]中的一个值,表示应出现术语的文档(总数)的最小部分,以便添加到查找字典中。
试着降低它,看看你是否得到匹配。