<commit_before>h1. Delayed Deltas for Thinking Sphinx

h2. Installation

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

<pre><code>gem install ts-delayed-delta --source http://gemcutter.org</code></pre>

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

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

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

<pre><code>require 'thinking_sphinx/deltas/delayed_delta/tasks'</code></pre>

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

<pre><code>script/generate delayed_job</code></pre>

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

<pre><code>define_index do
  # ...
  
  set_property :delta => :delayed
end</code></pre>

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.

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

h2. 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:

<pre><code>rake thinking_sphinx:delayed_delta</code></pre><commit_msg>Adding a forgotten comma. Closes #7.<commit_after>h1. Delayed Deltas for Thinking Sphinx

h2. Installation

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

<pre><code>gem install ts-delayed-delta --source http://gemcutter.org</code></pre>

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

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

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

<pre><code>require 'thinking_sphinx/deltas/delayed_delta/tasks'</code></pre>

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

<pre><code>script/generate delayed_job</code></pre>

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

<pre><code>define_index do
  # ...
  
  set_property :delta => :delayed
end</code></pre>

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.

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

h2. 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:

<pre><code>rake thinking_sphinx:delayed_delta</code></pre>
{'fraction_non_alphanumeric': 0.11635423400129283, 'fraction_numerical': 0.006140917905623788, 'mean_word_length': 4.4298245614035086, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6459749', 'n_tokens_mistral': 1028, 'n_tokens_neox': 981, 'n_words': 374}