Sorry if this is already posted elsewhere in the group but I've
searched the mail group and found no solution to my situation with
has_many association in Thinking Sphinx.
Suppose a Post has many descriptions in many languages. I create two
table posts and descriptions
posts (id, title)
descriptions(post_id, lang, description)
posts table:
post_id | title
-----------------------------------
1 | Post One
descriptions table
post_id | lang | description
-------------------------------------------
1 | "EN" | this is the first line - in English
1 | "FR" | this is the second line - in French
I want to search for "any post whose EN description contains "first"
". So
I perform a query like this:
Post.search "first", :with => {:language_ids => "EN"} # this works,
returned the Post One
but, amazingly, if I do:
Post.search "first", :with => {:language_ids => "FR"}
Again, it returns the Post One while I have thought it should return
nothing!!!
Any one can explain why?
class Post < ActiveRecord::Base
has_many :descriptions
define_index do
indexes post_id, title
indexes descriptions.language_id, :as => :language_ids
end
end
--
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.