I have a model called Feature which has many annotations (Annotation model). The index looks like this:
define_index do
indexes annotations.value, :as => :annotations
# other indexes
has annotations.status(:name), :as => :annotation_status
where "statuses.name = 'current' AND (statuses_annotations.name = 'current' OR statuses_annotations.name IS NULL)"
set_property :delta => :delayed
end
An annotation can change it's value or it can become outdated (status change), in which case I update the delta attribute of the associated feature in an Annotation model callback. Setting the delta attribute to true spins off a delayed_job task to update the delta index. In a separate callback I'd like to perform a new search against the updated delta index, but I noticed that the search never reflects the current state of the index. This is no doubt because the delta jobs are not finished yet.
What would be the best strategy to deal with this scenario?
Thanks!
Andrea