Thinking Sphinx - sorting by a string attribute gets out of sync when changes are made

Posted by Scott Brown on Stack Overflow See other posts from Stack Overflow or by Scott Brown
Published on 2010-04-23T20:51:52Z Indexed on 2010/04/23 20:53 UTC
Read the original article Hit count: 349

I have a "restaurants" table with a "name" column. I've defined the following index:

indexes "REPLACE(UPPER(restaurants.name), 'THE ', '')", :as => :restaurant_name, :sortable => true

... because I want to sort the restaurant names without respect to the prefix "The ".

My problem is that whenever one of these records is updated (in any way) the new record jumps to the top of the sort order. If another record is updated, it also jumps ahead of the rest. I end up with two lists: a list of restaurants that have been updated since the last re-indexing and a list of those that haven't. Each respective list is in alphabetical order, but I don't understand why the overall list is getting segregated this way. I do have a delayed delta index set up, and I assume the issue is related to this.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby