autocomplete in Solr and sunspot

微笑、不失礼 提交于 2019-12-12 04:33:19

问题


I'm building a website with RoR and I use Sunspot and the solr Search Engine. I needed to use autocomplete functionality but I couldn't. I knew that Solr has a new thing called suggester but I don't know how to use this with sunspot and in a rails app.

I found a gem called sunspot_autocomplete and I followed what was written, but when I try to reindex I get this error :

rake aborted!
RSolr::Error::Http - 400 Bad Request
Error: ERROR:unknown field 'tags_ac'

The model that is searchable called Experience and I put this block in it

searchable do
  text :tags, :boost => 3
  text :title, :boost => 2
  text :tips
  autocomplete :tags, :using => :tags
end 

Finally I found this blog that it sounds good but I don't understand it :(

http://www.binrand.com/post/3338898-autocomplete-solr-architecture-rails-3-2-solr-1-4-with-sunspot-solr-gem.html

I need your help in putting the autocomplete functionality in my app. Thanks A lot :)

Update: I finally fixed and made a demo here in the search box.


回答1:


i had the same "problem" =)

just ensure you have correct schema.xml with "autocomplete" type and fields defined at your solr schema path http://localhost:8982/solr/admin/file/?file=schema.xml (assuming you have local default sunspot dev environment)

for me, i had other one from other project ran at this path (and port)

you can see which one you have in the top of http://localhost:8982/solr/admin/ as SolrHome

hope it helped!




回答2:


I am having a similar problem, but I don't think it was related. However, I did find another version of that article that actually includes the code sections that are missing from OP's link.

https://gist.github.com/2648514

hope that helps!



来源:https://stackoverflow.com/questions/12357220/autocomplete-in-solr-and-sunspot

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