I'm doing a multi-model search, and it's important that models are
shown in a particular order. After searching how to do this in the
discussions, I stumbled upon one of the first questions in the group,
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/5dce1209ec9ffe92
where Pat suggested to use :sort_by => "class_crc ASC, @relevance
DESC" . I had been searching for something like class_crc, so this is
a good start. (Thanks Pat!) However, I'd like to customize how it
orders the classes. I'm using the following search:
ThinkingSphinx::Search.search(cleaned_query,
:classes => [Specialty, Store, MenuCategory, Food],
:sort_mode => :extended,
:sort_by => "class_crc ASC, @relevance DESC", :limit => 100 )
I wanted to sort Specialties at the top, Foods at the bottom. This
doesn't happen when sorting by class_crc. Is there a way that I can
sort by class in the order I'd like? I can't imagine that it'd be wise
to override 'to_crc32', perhaps I could add a new class method? But
I'm not sure how class_crc is tied to to_crc32.
The only other solution I can think of is to make sure that all
indexed fields are unique, and to add extra weight to Specialty
fields, less weight to Food fields, etc, but this seems a little
silly. I also thought of running 4 separate queries, or sorting the
results with Ruby afterwards, but both of those solutions mess with
pagination, and aren't so great efficiency-wise either.