我是Solr的新手,并希望基于两个字段标题和说明实现自动完成功能。另外,结果集应该被其他字段进一步限制,如id和category。样本数据:来自多个字段的solr自动完成关键字
Title: The brown fox lives in the woods
Description: The fox is found in the woods where brown leaves cover the ground. The animal's fur is brown in color and has a long tail.
期望中的自动完成结果:
brown fox
brown leaves
brown color
下面是schema.xml中的相关条目:
<fieldType name="autocomplete" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="25" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="id" type="int" indexed="true" stored="true"/>
<field name="category" type="string" indexed="true" stored="true"/>
<field name="title" type="text_general" indexed="true" stored="true"/>
<field name="description" type="text_general" indexed="true" stored="true"/>
<field name="ac-terms" type="autocomplete" indexed="true" stored="false" multiValued="true" omitNorms="true" omitTermFreqAndPositions="false" />
<copyField source="title" dest="ac-terms"/>
<copyField source="description" dest="ac-terms"/>
查询请求:
http://localhost:9090/solr/select?q=(ac-terms:brown)
感谢这样一个很好的例子。有没有办法让这些结果具有权重来订购它们? – lennard