class Media < ActiveRecord::Base
belongs_to :series, :class_name => 'Media', :foreign_key => 'series_id'
define_index do
indexes title
has 'IF(series_id, series_id, id)', :type => :integer, :as =>
:parent_media
end
end
Okay, basically i have a media class that is self-referencing, which is to
say that a record may or may not point to another record through the
series_id FK - this series_id can be null. Each record has a num_votes
column.
What I'd like to do when indexing is use the num_votes of the series IF
there is a related series record and if not use the num_votes of the current
record. So far, I have tried these:
has 'IF(series_id, series_medias.num_votes, num_votes)', :type => :integer,
:as => :sort_media_rank
has series ? series(:num_votes) : :num_votes
is it even possible to do a conditional for a has clause?
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.