autocomplete - How to get Suggestions in Solr 5.3.0 -


i trying implement auto complete feature using solr 5.3.0

solrconfig.xml looks 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 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 use analyzer admin panel of solr, can see indexed ngrams. , points out match.

however when use query:

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

i 0 suggestions. response here: https://api.myjson.com/bins/47r3i

there exists value "jindal panther" name key in 1 of docs.

moreover, have found if create dummy copyfield "suggest" type "string", source "name", suggestion works fine on "name" not work on "suggest". can misconfiguration of copyfield enable suggestions?

any appreciated. in advance.

edit: got solution. see accepted answer , comments below. there blog encountered beautifully explains suggesters. worth reading newbie solr search.

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

the field on want configure suggester should store=true. need not indexed. suggester configuration build dictionary according provide configuration in suggestcomponet. name field have stored true suggest_ngram not. need update schema configuration this:

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

also need provide parameter suggest.dictionary, dictionary using suggestions. names default.

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

or can provide dictionary configuration in requesthandler of /suggest:

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

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -