Friday, April 23, 2010

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

Programmer Question

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.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails