Hi all,
I've got an STI model setup to have separate indexes as follows:
class Organization < ActiveRecord::Base
define_index do
indexes name
end
end
class School < Organization
has_many :teachers_join
has_many :teachers :through => :teachers_join
define_index do
indexes name
has teachers(:user_id), :as => :teacher_ids, :type => :integer
end
end
What isn't working for me is doing something like:
School.search('High', :with => {:teacher_ids => User.first.id)})
I'd expect that to find me all the Schools belonging to User.first
(assuming they were a teacher) with "High" in the name. However,
regardless of what I put in as a :with (or :without) it just returns
me all the schools with "High" in the name.
I did some digging it looks like School.search_indexes has both
school_core and organization_core in it, and it seems that
because :teacher_ids isn't an attribute on organization_core, those
filters just get ignored. If I make it so that the sphinx_indexes of
School only contains the School index by adding:
class << self
def add_sphinx_index(index)
super if index.model == self
end
end
to my School class then it works as I expected it to.
So my questions are:
* Anyone else had this sort of problem?
* Would this have any other side-affects?
* Should I wrap this up in a more sensible patch?
Cheers
Murray
--
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.