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!
Of course, that’s an extremely simple overview. It’s definitely worth reading some more for a better understanding of the best ways to index and search.