Sphinx search with delta indexing thanks to Ultrasphinx

Evan Weaver has just announced delta indexing support for his UltraSphinx Rails plugin.

Delta indexing speeds up your updates by not reindexing the entire dataset every time.

First, in your .base file, set the indexer option delta to your maximum interval between full reindexes. A day or a week is good, depending. Add a little bit to account for the time it takes the actual index to run:

delta = <%= 1.day + 30.minutes %>

Now, configure your models for delta indexing in the is_indexed call:

is_indexed :fields => ['created_at', 'title', 'body'], :delta => true

Now you can run rake ultrasphinx:index:delta frequently, and only records that were changed within 1 day will be reindexed. You will need to run rake ultrasphinx:index:main once a day to move the delta contents into the main index.

From the UltraSphinx documentation.

I’ve previously written about how fast Sphinx search is in Rails searching with Sphinx using the acts_as_sphinx plugin (and also contributed a chapter to the Advanced Rails Recipes book using the UltraSphinx plugin). I’d now recommend using the UltraSphinx plugin if you want to take advantage of Sphinx for your Rails application.

In my opinion, this completes the ‘missing’ piece of functionality and should make Sphinx your default full-text search engine (if you’re using MySQL).


About this entry