我正在使用solr使用EdgeNGrams进行自动完成搜索。我使用solr 3.3并且我想使用来自建议器的排序作为多项搜索的自动完成解决方案。不幸的是,建议者只返回一个多项搜索的排序规则
如果用户正在搜索员工姓名,则应该应用自动完成功能。即,想要谷歌搜索等结果。它在我的配置下工作正常。
<fieldType name="edgytext" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory" />
<filter class="solr.LowerCaseFilterFactory" />
<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="15" side="front" />
</analyzer>
<field name="title" type="edgytext" indexed="true" stored="true" omitNorms="true" omitTermFreqAndPositions="true"/>
<field name="empname" type="edgytext" indexed="true" stored="true" omitNorms="true" omitTermFreqAndPositions="true" />
<field name="autocomplete_text" type="edgytext" indexed="true" stored="false" multiValued="true" omitNorms="true" omitTermFreqAndPositions="false" />
<copyField source="empname" dest="autocomplete_text"/>
<copyField source="title" dest="autocomplete_text"/>
网址:$ http:// local:8080 / test / suggest /?q = michael
Result :
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
</lst>
<result name="response" numFound="0" start="0" />
<lst name="spellcheck">
<lst name="suggestions">
<lst name="michael">
<int name="numFound">9</int>
<int name="startOffset">0</int>
<int name="endOffset">7</int>
<arr name="suggestion">
<str>michael bolton</str>
<str>michael foret</str>
<str>michael force</str>
<str>michael w. smith featuring andrae crouch</str>
</arr>
</lst>
<str name="collation">michael bolton</str>
</lst>
</lst>
</response>
这对我来说很好。当我用“michael f”搜索时,得到如下的响应。 (http:// local:8080 / test / suggest /?q = michael f)
回应:
<?xml version="1.0" encoding="UTF-8" ?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">1</int>
</lst>
<result name="response" numFound="0" start="0" />
<lst name="spellcheck">
<lst name="suggestions">
<lst name="michael">
<int name="numFound">9</int>
<int name="startOffset">0</int>
<int name="endOffset">7</int>
<arr name="suggestion">
<str>michael bolton</str>
<str>michael foret</str>
<str>michael force</str>
<str>michael w. smith featuring andrae crouch</str>
.....
</arr>
</lst>
<lst name="f">
<int name="numFound">10</int>
<int name="startOffset">8</int>
<int name="endOffset">9</int>
<arr name="suggestion">
<str>f**k the facts</str>
<str>fairest lord jesus</str>
<str>franz ferdinand</str>
<str>françois rauber</str>
.........
</arr>
</lst>
<str name="collation">michael bolton f**k the facts</str>
</lst>
</lst>
</response>.
所以当我用“michael f”搜索时,我应该只获得“michael foret”和“michael force”。数据以“f”开头。如果我在solr中的配置设置有任何问题,请建议我。
先谢谢,
阿尼尔。