solr autocomplete with scope is it possible?

风格不统一 提交于 2020-01-15 11:44:31

问题


I'm dig into solr configuration stuff and try to figure out how implement autocomplete feature.

Some details mentioned here http://wiki.apache.org/solr/Suggester/

But I don't want use same dictionary for all site - it is not useful when you have some private data. I mean several companies use search and I want make autocompleate based only on company data. Is it possible to limit autocompleate results scope them with some syntax.

I'm working with Rails 3 and sunspot gem and solr 3.6

Update:

I found gem which updated for rails 3 and necessary configuration documented here is it https://github.com/xponrails/sunspot_autocomplete

Both answers help me to do thats


回答1:


Unfortunately it's not possible to filter auto-suggestions made through the Suggester. You might want to have a look at this blog I wrote for other options you have. You should consider using either the facet prefix or the NGrams solution described in the article. The Ngrams solution is more flexible and a little more performant I guess but will cause the growth of your index size, while the facet prefix method is ready to go but probably slower. Just give them a try to see which one you prefer.




回答2:


I am using an EdgeNgram field and make the autocomplete queries against it.

Something like this in your schema.xml:

<field name="title_auto" type="edge_ngram" indexed="true" stored="true" multiValued="false" />

Querying "test" looks like

Jul 20, 2012 12:28:58 PM org.apache.solr.core.SolrCore execute
INFO: [collection1] webapp=/solr path=/select/ params={spellcheck=true&sort=date+desc fl=*+score&start=0&q=title_auto:(test)&spellcheck.count=1&spellcheck.collate=true&wt=json hits=0 status=0 QTime=2

Even though I am using a third party app to send out the queries to Solr (Django-Haystack), the above query should be similar to what you are looking for.



来源:https://stackoverflow.com/questions/11575727/solr-autocomplete-with-scope-is-it-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!