Received: by 10.68.211.233 with SMTP id nf9mr494799pbc.2.1349122995554; Mon, 01 Oct 2012 13:23:15 -0700 (PDT) X-BeenThere: thinking-sphinx@googlegroups.com Received: by 10.68.226.100 with SMTP id rr4ls24425492pbc.2.gmail; Mon, 01 Oct 2012 13:23:13 -0700 (PDT) Received: by 10.68.242.37 with SMTP id wn5mr4278601pbc.4.1349122993549; Mon, 01 Oct 2012 13:23:13 -0700 (PDT) Date: Mon, 1 Oct 2012 13:23:12 -0700 (PDT) From: "Andrea S." To: thinking-sphinx@googlegroups.com Message-Id: <64153286-229c-4023-9f6c-8fd6b38bdd9f@googlegroups.com> Subject: Checking if TS delayed delta job is finished MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_895_26635895.1349122992267" ------=_Part_895_26635895.1349122992267 Content-Type: multipart/alternative; boundary="----=_Part_896_19814625.1349122992267" ------=_Part_896_19814625.1349122992267 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit I was wondering whether there is an easy way to check that a TS delayed delta job has finished? I have a scenario in which I need to run a new search in an after_save callback and of course I'd like to see the changes to the delta index reflected in the search results. Here are some details of my example: 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 ------=_Part_896_19814625.1349122992267 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit I was wondering whether there is an easy way to check that a TS delayed delta job has finished? I have a scenario in which I need to run a new search in an after_save callback and of course I'd like to see the changes to the delta index reflected in the search results.

Here are some details of my example:

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

------=_Part_896_19814625.1349122992267-- ------=_Part_895_26635895.1349122992267--