I have several questions about delta indexing when a model's index is separated into multiple indices.
In this example:
ThinkingSphinx::Index.define :model, name: "index_1", with: :active_record, delta: ThinkingSphinx::Deltas::ResqueDelta do
indexes :field_a
end
ThinkingSphinx::Index.define :model, name: "index_2", with: :active_record, delta: ThinkingSphinx::Deltas::ResqueDelta do
indexes :field_b
end
I get these files for each index:
model_index_1_delta
model_index_2_delta
model_index_1_core
model_index_2_core
field_a
, will model_index_2_delta
also get updated?If both field_a
and field_b
are updated on a record:
a. Will a re-index update both model_index_1_core
and model_index_2_core
simultaneously?
b. When will the record's delta field be set to 0 in the DB?
c. Will one of the core files not get updated correctly if the delta field was set to 0 already by a previous re-index run?
Yes, if you update field_a, both deltas will be updated. Thinking Sphinx does not try to figure out whether model changes are relevant to a specific index.
a. It depends on how deltas are processed. If it's the default delta
processor (:delta => true
), then they're processed one after the
other. You're using Resque, so the processing of each index could
indeed overlap. That's fine, though.
b. The delta flag is only set to false/zero when a full index happens via the rake ts:index
task, and only set to true/one by delta processing. It remains set to true until the rake task is run - it's an indication of whether there are changes not present in core (rather than an indication that it just needs to be processed for the delta index).
c. The core indices load all data when rake ts:index
is run - there is no filter on the delta column.