Hi,
I installed Sphinx and Thinking-Sphinx some days ago on my ruby on rails 2.3.2, and basic searching works great. This means, without any conditions. Now, I want to filter the search with some conditions.
I have the Announcement model, and the index looks as follows:
define_index do
indexes title, :as => :title, :sortable => true
indexes description, :as => :description, :sortable => true
end
Maybe I'm wrong, but I noticed that only when I added the :sortable => true
syntax to these attributes, I could use them as conditions in my search. Otherwise it won't find anything.
Now, I'm also using acts_as_taggable_on plugin, which generated my two db tables: tags and taggings. I don't have a model for tags, I just have acts_as_taggable_on :tags, :categories
at my Announcements model.
What I'd like to do now is to filter by tags. So, I tried adding to my index has tags(:id), :as => :tag_ids
with no luck, and also indexes tags(:id), :as => :tag_ids
but it didn't work either.
How can I build the indexes so I can do something like this:
Announcement.search 'some word', :conditions => {:tag_ids => some_id}
And also, which is the different between has
and indexes
Thanks, Brian