If have multiple indexed models that have a verification level which need to be sorted by their verification level.
But I also have a couple of models without a verification level.
ThinkingSphinx.search @search.q, :order => 'class_crc ASC, @relevance DESC, verification_level DESC', :page => page, :limit => limit, :classes => @search.types_as_models
The problem is I can rank by verification_level on models that have that attribute but it errors on models without a verification_level
index ground_core,ground_delta,user_core,user_delta: sort-by attribute 'verification_level' not found
Example player define_index with verification_level
define_index do
indexes [first_name, last_name], :as => :name, :sortable => true
where "state = 1"
has created_at, updated_at, verification_level
set_property :delta => ThinkingSphinx::Deltas::ResqueDelta
end
Example User define_index without verification_level
define_index do
indexes [first_name, last_name], :as => :name, :sortable => true
has created_at, updated_at
set_property :delta => ThinkingSphinx::Deltas::ResqueDelta
end
Is there a way to sort when it is on a model and ignore when it isnt?
My solution was to fake a verification level on models which didn’t require it by adding it in the define_index block
has '0', :as => :verification_level, :type => :integer