试图实现与Solr的范围的自动建议 [英] Trying to implement scoped autosuggestions with solr
问题描述
我想在像亚马逊等。
的电子商务网站实施类似范围的自动建议如。
如果我键入乐高,建议应该像
-
乐高拉斯在名称
-
乐高在玩具
其中的名称和精品是Solr的字段名。
我得到的最接近的援助是本次讨论:
Solr的自动完成与范围,这可能吗?
这告诉我,这是不可能的 suggester 我我目前使用。
到现在为止,使用suggester我能够从一个单一的Solr场实现自动建议。 [自动提示领域,suggester文档中的准则]
任何想法/链接帮助我?
更新
我尝试使用方面来实现自动建议。我的查询看起来是这样的:
<$p$p><$c$c>http://localhost:8983/solr/core1/select?q=*%3A*&rows=0&wt=json&indent=true&facet=true&facet.field=field1&facet.field=field2&facet.$p$pfix=i这给了我所有的方面结果,从字母'I'和期限多面到FIELD1和Field2。
这给我的想法。
任何意见?
您可以添加多个suggester组件。
添加一个用于每个字段。
例如。
&LT;的SearchComponent名称=建议级=solr.SuggestComponent&GT;
&LT; LST NAME =suggester&GT;
&LT; STR名=名与GT; namesSuggester&LT; / STR&GT;
&LT; STR NAME =lookupImpl&GT; BlendedInfixLookupFactory&LT; / STR&GT;
&LT; STR NAME =dictionaryImpl&GT; DocumentDictionaryFactory&LT; / STR&GT;
&LT; STR NAME =场&GT;名称&LT; / STR&GT;
&LT; STR NAME =weightField&GT;大众化与LT; / STR&GT;
&LT; STR NAME =indexPath&GT; namesSuggesterIndexDir&LT; / STR&GT;
&LT; STR NAME =suggestAnalyzerFieldType&GT; suggester&LT; / STR&GT;
&LT; / LST&GT;
&LT; LST NAME =suggester&GT;
&LT; STR名=名与GT; toysSuggester&LT; / STR&GT;
&LT; STR NAME =lookupImpl&GT; BlendedInfixLookupFactory&LT; / STR&GT;
&LT; STR NAME =dictionaryImpl&GT; DocumentDictionaryFactory&LT; / STR&GT;
&LT; STR NAME =场&GT;玩具与LT; / STR&GT;
&LT; STR NAME =weightField&GT;大众化与LT; / STR&GT;
&LT; STR NAME =indexPath&GT; toysSuggesterIndexDir&LT; / STR&GT;
&LT; STR NAME =suggestAnalyzerFieldType&GT; suggester&LT; / STR&GT;
&LT; / LST&GT;
&LT; /&的SearchComponent GT;
I am trying to implement scoped autosuggestions like in ecommerce websites like amazon etc.
eg. if i type Lego , the suggestions should come like
Legolas in Names
Lego in Toys
where Names and Toys are solr field names.
closest aid i got is from this discussion: solr autocomplete with scope is it possible?
Which informed me that it isn't possible with the suggester which I am currently using.
Until now, using the suggester I am able to achieve autosuggestions from a single solr field. [the autosuggest field , following guidelines in the suggester documentation]
Any ideas/links to help me with ?
Update
I tried to achieve autosuggestions using facets. My query looks something like:
http://localhost:8983/solr/core1/select?q=*%3A*&rows=0&wt=json&indent=true&facet=true&facet.field=field1&facet.field=field2&facet.prefix=i
This gives me all the facet results starting with letter 'i' and term faceted to field1 and field2.
This gave me the idea.
Any comments?
You can add multiple suggester components. Add one for each field.
E.g. :
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">namesSuggester</str>
<str name="lookupImpl">BlendedInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">Names</str>
<str name="weightField">Popularity</str>
<str name="indexPath">namesSuggesterIndexDir</str>
<str name="suggestAnalyzerFieldType">suggester</str>
</lst>
<lst name="suggester">
<str name="name">toysSuggester</str>
<str name="lookupImpl">BlendedInfixLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">Toys</str>
<str name="weightField">Popularity</str>
<str name="indexPath">toysSuggesterIndexDir</str>
<str name="suggestAnalyzerFieldType">suggester</str>
</lst>
</searchComponent>
这篇关于试图实现与Solr的范围的自动建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!