I've set up some indices and everything seems to work nicely, until I wanted to try getting the results sorted. I have several models, but the the one in which I am defining my indices is "Doctor". I'm defining them like this:
class SearchController < ApplicationController
define_index do
indexes :firstname, :sortable => true
indexes :lastname, :sortable => true
indexes :sex, :sortable => true
indexes practice(:name), :as => :practice_name, :sortable => true
indexes practice(:address), :as => :practice_address, :sortable => true
# Added after denormalization
indexes county(:name), :as => :county
indexes municipality(:name), :as => :municipality
# Can only filter on integers, thus CRC32-ing
has "CRC32(sex)", :as => :sex_filter, :type => :integer
end
end
Searching seems to be working just fine. When trying to sort on any of the attributes, I get an error like the following
index employee_core: sort-by attribute 'firstname' not found
For firstname, lastname and sex. I am able to partially "solve" this by adding
has firstname, lastname, sex
to the define_index block, but I'm not sure how to do the same for the references to another model (Practice), or if it is even possible.
Anyone know what I might be doing wrong in the first place to make the :sortable => true not work, or how I might define the references to Practice as attributes as well?
An example of the call I'm making to Thinking Sphinx which is failing in the manner mentioned above:
ThinkingSphinx.search "<some search string>", {:with=>{}, :order=>:firstname, :sort_mode=>:desc, :page=>1}
rake ts:rebuildafter adding:sortable => true? - Vasiliy Ermolovich