Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Manage delta indexes via datetime columns for Thinking Sphinx

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.textile

Datetime Deltas for Thinking Sphinx

This fork should hopefully make it a bit more Rails 3 compatible, by moving the task to the lib/tasks folder and renaming the file to delta.rake.
Using this strategy delta.rake should be merged with the Rails 3 app lib/tasks folder and should thus be recognized by rake.

Installation

You’ll need Thinking Sphinx 1.3.0 or later.

gem install ts-datetime-delta --source http://gemcutter.org

In your environment.rb file, with the rest of your gem dependencies:

config.gem 'ts-datetime-delta',
  :lib     => 'thinking_sphinx/deltas/datetime_delta'
  :version => '>= 1.0.0',
  :source  => 'http://gemcutter.org'

And add the following line to the bottom of your Rakefile:

require 'thinking_sphinx/deltas/datetime_delta/tasks'

Usage

For the indexes you want to use this delta approach, make sure you set that up in their define_index blocks.

define_index do
  # ...
  
  set_property :delta => :datetime
end

If you want to use a column other than updated_at, you can specify it using the :delta_column option. The same goes for the threshold, which defaults to one day.

set_property :delta => :datetime,
  :threshold    => 1.hour,
  :delta_column => :changed_at

Then, while your Rails application is running, you’ll need to run the delta indexing rake task regularly – as often as your threshold, allowing for some time for the indexing to actually happen.

For example, if you’re going to run the delta indexing task every hour, I would recommend setting your threshold to 70 minutes.

To ensure this rake task is called regularly, it’s best to set it up as a recurring task via cron or similar tools.

rake thinking_sphinx:index:delta

The shorthand version is:

rake ts:in:delta

Copyright

Copyright © 2009 Pat Allan, and released under an MIT Licence.

Something went wrong with that request. Please try again.