DJ delta indexing: Can I avoid delta indexing for non searchindex relevant model attribute changes?

Nico's Avatar

Nico

17 Aug, 2011 02:58 PM

I have a user model that has a last_active attribute that is constantly updated when a user is logged in. Any such update causes sphinx to create delta indexing dj jobs, although no fields relevant for the serach are updated. How can I avoid this?

  1. Support Staff 1 Posted by Pat Allan on 18 Aug, 2011 01:39 AM

    Pat Allan's Avatar

    Hi Nico

    The following (or something similar) should do the trick:

    User.suspended_delta(false) { user.update_attributes(:last_active => Time.zone.now) }
    

    The false flag tells TS to not run a delta index request after the block is complete (it defaults to true).

  2. 2 Posted by Nico on 18 Aug, 2011 06:10 AM

    Nico's Avatar

    Thanks, I give it a shot.

  3. 3 Posted by Nico on 18 Aug, 2011 06:43 AM

    Nico's Avatar

    Just wondering if thinking sphinx could figure out automatically if relevant fields have changed on a save and then conditionally trigger the (delayed) delta indexing?

  4. Support Staff 4 Posted by Pat Allan on 18 Aug, 2011 06:49 AM

    Pat Allan's Avatar

    It does try to - but if you're using associations or SQL snippets in fields and attributes, it can't be sure, so it works with the assumption that it's better to fire a delta request.

  5. 5 Posted by Nico Ritsche on 18 Aug, 2011 07:11 AM

    Nico Ritsche's Avatar

    Ah, okay, sounds reasonable.

    Thanks for making sphinx available on Heroku by the way. Great job! ;-)

  6. Support Staff 6 Posted by Pat Allan on 18 Aug, 2011 07:14 AM

    Pat Allan's Avatar

    Thanks :)

  7. Pat Allan closed this discussion on 18 Aug, 2011 07:14 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac