-
Notifications
You must be signed in to change notification settings - Fork 9
ThinkingSphinx Site Search
Some brief notes on setting up Thinking Sphinx site search in a BCMS implementation.
First, learn about and install “thinking sphinx”: http://freelancing-god.github.com/ts/en/ .
The hooks between TS and BCMS models can be created very easily by subclassing whatever you want to index in your search.
class SphinxPage < Page define_index do indexes name indexes title indexes keywords indexes connector.connectible has published end end
This file is in my lib directory, and I require it in my environment.rb . From here on in, I only have to ‘rake ts:rebuild’ (to get the sphinx configuration set up) and ‘rake ts:in’ to reindex new data.
Everything is straightforward usage for ThinkingSphinx. I set up a search controller at the front:
map.connect "/search", :controller => "search", :action => "search" map.namespace('cms') do |cms| cms.resources :datasets, :only => [:show, :index], :member => {:hide => :get, :publish => :get}, :has_many => :annotations end
It my go without saying, but in addition I hang a search form on the default cms template (in my case app/views/layouts/templates/default.html.ren) as well as the application layout. The search form posts to the search controllers, which renders on a results action and template. This is bog standard search stuff which doesn’t have to be explained here.