You’re right, update_all doesn’t fire callbacks, and given you’re not using the status column in your index, that shouldn’t be a problem.
The duplicate records is an odd thing though. Are you finding _every_ result is duplicated? Only ones impacted by the cron job? Or are other records duplicated as well? Also: which version of Thinking Sphinx are you using? — Pat > On 5 Jul 2016, at 9:20 PM, pratik ganvir <[email protected]> wrote: > > Hi Pat, > > Thanks for the reply. Here is my index definition. > > ThinkingSphinx::Index.define :text_message, :with => :real_time do > has contact_group_id, type: :integer > has user_id, type: :integer > has id, :as => :sms_id, type: :integer > has sms_campeign_id, :as => :sms_campeign_id, type: :integer > has delivery_schedule, :type => :timestamp, :sortable => true > has created_at, :type => :timestamp, :sortable => true > end > > I am suing update_all method in my cron which surely doesn't fire callbacks. > Here is the cron method that does that. > > def self.update_system_errors > sms = Sms.where('status not in (?) and (created_at between ? > and ?) and job_id in > (?)',[10,11],DateTime.now.beginning_of_day,DateTime.now.end_of_day,["Daily > Message Limit Reached"]) > sms.update_all('status = 10') > sms = Sms.where('status not in (?) and (created_at between ? and ?) and > job_id in > (?)',[10,11],DateTime.now.beginning_of_day,DateTime.now.end_of_day,["Sender > ID Does not Exist or Pending or Route Invalid!","No Sufficient Credits""]) > sms.update_all('status = 11') > end > > Thanks, > Pratik Ganvir > > On Sunday, 3 July 2016 16:46:43 UTC+5:30, Pat Allan wrote: > Hi Pratik > > Can you share your index definition? Also, how are you updating the > TextMessage records via your cron process? Is it in a manner that will fire > ActiveRecord callbacks? And is this the only model you have with a Sphinx > index? > > Cheers > > — > Pat > >> On 2 Jul 2016, at 1:45 PM, pratik ganvir <[email protected] <javascript:>> >> wrote: >> >> Hi, >> >> So I have a model called TextMessage which has attributes id and user_id. I >> am using real time indices. >> There is one cron process that updates the status field of TextMessage >> records. When it does that, following query returns 2 records for each >> database record. >> >> TextMessage.search(with: {user_id: current_user.id >> <http://current_user.id/>},order: 'created_at desc',page: params[:page], >> per_page: 10 ) >> >> When I rebuild the index then everything goes fine. But considering the fact >> that I am using realtime indices I do not want to rebuild indexes everytime. >> >> Please help me to get through this. >> >> Thanks and regards, >> Pratik >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Thinking Sphinx" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/thinking-sphinx >> <https://groups.google.com/group/thinking-sphinx>. >> For more options, visit https://groups.google.com/d/optout >> <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "Thinking Sphinx" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/thinking-sphinx > <https://groups.google.com/group/thinking-sphinx>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/thinking-sphinx. For more options, visit https://groups.google.com/d/optout.
