How can I temporarily disable delta indexing with Thinking Sphinx?
Asked Answered
T

2

6

I am running a big migration and would like to disable delta indexing so it runs much faster.

Is there a way to specify in the beginning of the task to turn delta indexing off?

Trilogy answered 30/4, 2011 at 13:10 Comment(0)
M
14

Two options:

Model.suspended_delta do
  # all actions in the block don't fire a delta request
end
# A single delta request gets fired at the end

Or, what may be better in your situation:

ThinkingSphinx.deltas_enabled = false

And set it back to true when you're done.

Mannerheim answered 1/5, 2011 at 0:39 Comment(1)
FYI: This is for older versions of ts. See below answer for newer versions.Domineering
M
9

For thinking sphinx v3, you can suspend the deltas this way (the old way is deprecated):

ThinkingSphinx::Deltas.suspend(:index_reference) do
  # Do something
end

So if I have a model called Job with an index named :job, it would look like this:

ThinkingSphinx::Deltas.suspend(:job) do
  # Do Something
end
Maribelmaribelle answered 4/8, 2013 at 0:10 Comment(1)
And there's also the ThinkingSphinx::Deltas.suspend! and ThinkingSphinx::Deltas.resume! methods if you want to control things at a finer level - but this won't automatically run delta indexing for any models afterwards.Mannerheim

© 2022 - 2024 — McMap. All rights reserved.