thinking sphinx
Current Version
0.9.5Quickstart
Okay, here’s the brief explanation of how to set up Thinking Sphinx.
Install Sphinx
Go grab the files you need from the Sphinx site.
Install Thinking Sphinx
script/plugin install
git://github.com/freelancing-god/thinking-sphinx.git
If you’re not on edge, use the following:
git clone git://github.com/freelancing-god/thinking-sphinx.git
vendor/plugins/thinking-sphinx
Once you’ve got a full clone, you can switch to a specific tag or branch:
git checkout v0.9.5
If you’re not using git, just download the tarball from the GitHub site.
Set up your indexes
Say you have an Article model, you might want to do something like the following – adapt to taste.
class Article < ActiveRecord::Base
# ...
define_index do
indexes subject, :sortable => true
indexes content
indexes author.name, :as => :author, :sortable => true
has author_id, created_at, updated_at
end
# ...
end
Index your data
Run the thinking_sphinx:index rake task.
Fire up Sphinx
Run the thinking_sphinx:start rake task.
Get Searching!
Again with an Article model:
Article.search "topical issue"
Article.search "something", :order => :created_at, :sort_mode => :desc
Article.search "everything", :conditions => {:author_id => 5}
Article.search :conditions => {:subject => "Sphinx"}
And that’s pretty much it – for more detail, check out the usage page.
Pat Allan, 2008
Theme extended from Paul Battley