A Quick Guide to Getting Setup with Thinking Sphinx
Note: This Guide is for Thinking Sphinx v3. If you can't use Ruby 1.9 or Rails/ActiveRecord 3.1 or newer, then you'll probably want the old guide for v2 releases instead.
Once that’s all done, it’s time to set up an index on your model. In the example below, we’re assuming the model is the Article class - and so we’re going to put this index in
app/indices/article_index.rb (the path matters, the file name is arbitrary, but should not be just the model’s name).
The above definition is for a real-time index, and so fields and attributes refer to your model’s methods.
You’ll want to add a callback to your model to ensure any changes flow through to Sphinx:
The next step is to process your data (this task stops the Sphinx daemon if it is running, deletes existing Sphinx data, rewrites the Sphinx configuration file, starts the Sphinx daemon again, and then creates Sphinx documents for each indexed model instance):
And now we can search!