如何获得在Solr的5.3.0建议 [英] How to get Suggestions in Solr 5.3.0

查看:154
本文介绍了如何获得在Solr的5.3.0建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现使用Solr的5.3.0自动完成功能

solrconfig.xml中看起来像这样

 <的SearchComponent名称=建议级=solr.SuggestComponent>
  < LST NAME =suggester>
    < STR名=名与GT;默认< / STR>
    < STR NAME =lookupImpl> FuzzyLookupFactory< / STR>
    < STR NAME =dictionaryImpl> DocumentDictionaryFactory< / STR>
    < STR NAME =场> suggest_ngram< / STR>
    < STR NAME =weightField>的价格和LT; / STR>
    < STR NAME =suggestAnalyzerFieldType> text_suggest_ngram< / STR>
    < STR NAME =buildOnStartup>真< / STR>
  < / LST>
< /&的SearchComponent GT;< requestHandler NAME =/提示级=solr.SearchHandler启动=懒>
< LST NAME =默认>
  < STR NAME =建议>真< / STR>
  < STR NAME =suggest.count大于10< / STR>
< / LST>
< ARR NAME =组件>
  < STR>建议< / STR>
< / ARR>

托管模式是这样的:

 <字段类型名称=text_suggest_ngram级=solr.TextFieldpositionIncrementGap =100>
<分析型=指数>
< tokenizer类=solr.StandardTokenizerFactory/>
  <过滤器类=solr.LowerCaseFilterFactory/>
  <过滤器类=solr.EdgeNGramFilterFactorymaxGramSize =10minGramSize =2/>
< /分析仪>
<分析型=查询>
  < tokenizer类=solr.StandardTokenizerFactory/>
  <过滤器类=solr.LowerCaseFilterFactory/>
< /分析仪>
< /字段类型>
<字段名=suggest_ngramTYPE =text_suggest_ngram收录=真正的存储=FALSE/>
<字段名=姓名类型=字符串多值=false的索引=真正的存储=真/>
<字段名=价格型=腾龙多值=false的索引=真正的存储=真/>
< copyField源=名字目标=suggest_ngram/>

现在,当我使用分析器从Solr的的管理面板,可以看我的索引n元。它成功地指出了这场比赛。

然而,当我使用查询:

<$p$p><$c$c>http://localhost:8983/solr/products/suggest?suggest=true&suggest.build=true&wt=json&suggest.q=Jind

我得到0的建议。
响应是在这里:
https://api.myjson.com/bins/47r3i

有在文档中的一个名称键存在价值金达莱豹。

此外,我发现,如果我创建一个虚拟copyfield建议带有类型为字符串,以源作为名,即作品的名称精任何建议不会对建议的工作。这可以copyfield的任何错误配置,使建议?

任何帮助将是AP preciated。
先谢谢了。

编辑:
得到了解决。见接受的答案,并低于其意见。
还有的是,我遇到了美丽的解释Suggesters一个博客。这绝对是值得一读的新手到Solr搜索。

https://lucidworks.com/blog/2015/03/04 / Solr的-suggester /


解决方案

这是您要的suggester配置应商店= TRUE 的字段。它不需要被索引。该suggester配置将根据建立在 suggestComponet 将提供配置的字典。在名称字段都存储为真正,其中以 suggest_ngram 是不。您需要更新这样的模式配置:

 &LT;字段名=suggest_ngramTYPE =text_suggest_ngram收录=false的存储=真/&GT;

此外,你需要提供参数 suggest.dictionary ,您使用的建议字典。对你来说这是名作为默认

 的http://本地主机:8983 / Solr的/产品/提示提示=真放;
       suggest.build =真放;
       重量= JSON和放大器;
       suggest.dictionary =默认&安培;
       suggest.q = Jind

或者您可以提供 requestHandler /提示的字典组态:

 &LT; STR NAME =suggest.dictionary&GT;默认&LT; / STR&GT;

I am trying to implement auto complete feature using Solr 5.3.0

solrconfig.xml looks like this

<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
    <str name="name">default</str>
    <str name="lookupImpl">FuzzyLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">suggest_ngram</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">text_suggest_ngram</str>
    <str name="buildOnStartup">true</str>
  </lst>
</searchComponent>

<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy" >
<lst name="defaults">
  <str name="suggest">true</str>
  <str name="suggest.count">10</str>
</lst>
<arr name="components">
  <str>suggest</str>
</arr>

managed-schema looks like this:

<fieldType name="text_suggest_ngram" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.EdgeNGramFilterFactory" maxGramSize="10" minGramSize="2" />
</analyzer>
<analyzer type="query">
  <tokenizer class="solr.StandardTokenizerFactory"/>
  <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>


<field name="suggest_ngram" type="text_suggest_ngram" indexed="true" stored="false"/>
<field name="name" type="string" multiValued="false" indexed="true" stored="true"/>
<field name="price" type="tlong" multiValued="false" indexed="true" stored="true"/>
<copyField source="name" dest="suggest_ngram"/>

Now when I use the analyzer from the admin panel of Solr, I can see the indexed ngrams. And it successfully points out the match.

However when I use the query:

http://localhost:8983/solr/products/suggest?suggest=true&suggest.build=true&wt=json&suggest.q=Jind

I get 0 suggestions. The response is here: https://api.myjson.com/bins/47r3i

There exists a value "Jindal Panther" for the name key in one of the docs.

Moreover, I have found that if I create a dummy copyfield "suggest" with type as "String", with source as "name", any suggestion that works fine on "name" will not work on "suggest". Can this be any misconfiguration of copyfield to enable suggestions?

Any help would be appreciated. Thanks in advance.

EDIT: Got the solution. See the accepted answer and its comments below. There is a blog that I encountered that beautifully explains Suggesters. It is definitely worth reading for a newbie to Solr Search.

https://lucidworks.com/blog/2015/03/04/solr-suggester/

解决方案

The field on which you want to configure the suggester should be store=true. It need not to be indexed. The suggester configuration will build a dictionary according to the provide configuration in the suggestComponet. The name field have stored as true where as suggest_ngram is not. You need to update the schema configuration like this:

<field name="suggest_ngram" type="text_suggest_ngram" indexed="false" stored="true"/>

Also you need to provide the parameter suggest.dictionary, the dictionary you are using for suggestions. For you it is names as default.

http://localhost:8983/solr/products/suggest?suggest=true&
       suggest.build=true&
       wt=json&
       suggest.dictionary=default&
       suggest.q=Jind

OR you can provide the dictionary configuration in requestHandler of /suggest:

<str name="suggest.dictionary">default</str>

这篇关于如何获得在Solr的5.3.0建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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