freelancing-god / ts-delayed-delta

Manage delta indexes via Delayed Job for Thinking Sphinx

This URL has Read+Write access

name age message
file .gitignore Sun Nov 01 23:21:51 -0800 2009 First real commit [freelancing-god]
file LICENSE Sun Nov 01 16:46:28 -0800 2009 Initial commit to ts-delayed-delta. [freelancing-god]
file README.textile Wed Dec 23 15:15:06 -0800 2009 Adding Ryan Schlesinger as a contributor. [freelancing-god]
file Rakefile Sun Nov 01 23:21:51 -0800 2009 First real commit [freelancing-god]
file VERSION Tue Dec 01 16:49:51 -0800 2009 Updating to 1.0.2 [freelancing-god]
directory features/ Tue Dec 01 16:01:10 -0800 2009 Fixing test suite for TS references [freelancing-god]
directory lib/ Mon Dec 14 16:56:52 -0800 2009 Using latest TS search_for_id call. [freelancing-god]
directory spec/ Mon Dec 14 16:56:52 -0800 2009 Using latest TS search_for_id call. [freelancing-god]
directory tasks/ Wed Dec 23 09:54:02 -0800 2009 Added a rails.rake file for installing as a plu... [ryansch]
file ts-delayed-delta.gemspec Tue Dec 01 16:49:51 -0800 2009 Updating to 1.0.2 [freelancing-god]
README.textile

Delayed Deltas for Thinking Sphinx

Installation

You’ll need Thinking Sphinx 1.3.0 or later, and Delayed Job as well. The latter is flagged as a dependency.

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

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

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

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

require 'thinking_sphinx/deltas/delayed_delta/tasks'

If this is your first time running Delayed Job, then you’re going to need the jobs table migration as well:

script/generate delayed_job

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 => :delayed
end

If you’ve never used delta indexes before, you’ll want to add the boolean column named delta to each model that is using the approach.

def self.up
  add_column :articles, :delta, :boolean, :default => true, :null => false
end

Usage

Once you’ve got it all set up, all you need to do is make sure that the delayed job process is running – either by Delayed Job’s built-in approach, or Thinking Sphinx’s custom rake task:

rake thinking_sphinx:delayed_delta

There’s also a short name for the same task, to save your fingers some effort:

rake ts:dd

Contributors

Copyright

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