I'm doing an application search that might filter on several different fields - some of which are not present in every index.
At the moment sorting out the correct classes to search on in the controller, using a complicated if elsif elsif thing.
Is there a way to get thinking sphinx to automatically not search a model if one a condition field isn't present, rather than ignoring the condition as seems to happen at the moment.
Eg
ThinkingSphinx.search(@query, :conditions => {:genres =>"classical-music"}, :match_mode => :extended, :classes => [Performer, Promoter, Tour, Venue, User], :order => :name_sort, :sort_mode => :asc)
User doesn't have genres, but is included in the search results
update
It definitely doesn't work as I'd like. My user model doesn't have the genres field in the index, so I'd like it to be excluded when I search on genres.
Example searches
User.search("anne")
Sphinx Query (3.6ms) anne
Sphinx Found 1 result
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IN (80)
=> [#<User id: 80, first_name: "Anne", last_name: "Bowers", bio: nil, email: "anne@bowers.com", phone: nil, created_at: "2012-11-20 09:36:05", updated_at: "2012-11-20 09:36:05", role: nil, promoter_id: nil, performer_id: nil, job_title: nil>]
ThinkingSphinx.search("anne", :conditions => {:genres => "music"}, :match_mode => :extended, :classes => [User], :order => :name_sort, :sort_mode => :asc)
Sphinx Query (3.2ms) anne @genres music
Sphinx Found 1 result
User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` IN (80)
=> [#<User id: 80, first_name: "Anne", last_name: "Bowers", bio: nil, email: "anne@bowers.com", phone: nil, created_at: "2012-11-20 09:36:05", updated_at: "2012-11-20 09:36:05", role: nil, promoter_id: nil, performer_id: nil, job_title: nil>]
It'd be really good if the user was excluded.