如何在Solr中多个字段自动完成 [英] How to autocomplete across multiple fields in Solr

查看:131
本文介绍了如何在Solr中多个字段自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现使用Solr的suggester组件搜索自动完成功能。我想给在多个领域的建议。我有2场分类标记我想建议提供。例如,如果搜索查询是颈部那么它应该返回:

I am trying to implement auto-complete feature for search using Solr's suggester component. I want to give suggestions across multiple fields. I have 2 fields taxonomy and tag which I want to provide in suggestions. Eg if the search query is neck then it should return:

necklace
neckalce sets
pearl necklace
diamond necklace
pearl necklace sets
diamond necklace sets

其中,项链是一个分类和珍珠钻石有标记。

where necklace is a taxonomy and pearl and diamond are tags.

以下是我的schema.xml:

Following is my schema.xml:

<field name="suggestion" type="text_auto" indexed="true" stored="false" multiValued="false" />

<copyField source="taxonomy_name" dest="suggestion"/>
<copyField source="tag" dest="suggestion">

<fieldType name="text_auto" class="solr.TextField">
  <analyzer>
   <tokenizer class="solr.KeywordTokenizerFactory"/>
   <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

和我solrconfig.xml中:

and my solrconfig.xml:

<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">suggestion</str>  <!-- the indexed field to derive suggestions from -->
  <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>

但是,这将返回:

But this returns:

necklace
necklace sets

我怎样才能解决这个问题。我使用也尝试:

How can I fix this. I also tried using :

<fieldType name="text_auto" class="solr.TextField"> 
  <analyzer> 
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
    <filter class="solr.ShingleFilterFactory" maxShingleSize="2" outputUnigrams="false"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer> 
</fieldType> 

但是,这仅返回项链套

推荐答案

这添加到&LT; searchHandler&GT;

<str name="lookupImpl">AnalyzingInfixLookupFactory</str>

这将使你搜索珍珠项链为好,因为它承认一个词/短语/场中间的文字。

This will enable you to search pearl necklace as well, as it recognizes the text in the middle of a word/phrase/field.

这篇关于如何在Solr中多个字段自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆