Can you try the following in your Person index and see if it works:
has tvShowHosts.tvShow.id, :as => :tv_show_ids
And then searching:
Person.search :conditions => {gender: 'M'}, :with => {:tv_show_ids => 48}
--
Pat
On 4 Apr 2014, at 5:20 am, mamesaye kane <[email protected]> wrote:
> If select a tv show I find all the infos related to the people that has been
> in that show: gender (M, F, O) that were on it, their alignment (D, R, C, N,
> ...), ethnicity (W, B, A, ...)
> But my search doesn't return a result when i want to find all male(s) in a tv
> show (select tv show and M)
> I maybe missing an index.
>
> models
>
> class TvShow < ActiveRecord::Base
> attr_accessible :channel, :description, :name, :starting_time,
> :ending_time, :person_ids
> has_many :tvShowHosts
> has_many :episodes ,:foreign_key=>"tv_show_id"
> has_many :segments ,:foreign_key=>"tv_show_id"
> end
>
> class Episode < ActiveRecord::Base
> attr_accessible :broadcast_date, :comment,
> :tv_show_id,:segments,:segments_attributes,:balance
> has_many :segments
> belongs_to :tv_show
> end
>
> class Segment < ActiveRecord::Base
> attr_accessible :broadcast_date, :comment, :name, :person_id, :episode_id,
> :tv_show_id, :balance
> belongs_to :episodes
> belongs_to :tv_show
> has_many :personSegments
> has_many :people , :through => :personSegments
> end
>
> class Person < ActiveRecord::Base
> attr_accessible :alignment, :gender, :source, :ethnicity, :description,
> :first_name, :last_name , :profession_ids, :roles_attributes
>
> #tvshows
> has_many :tvShowHosts
> has_many :tvShows , :through => :tvShowHosts
> ,:foreign_key=>"tv_show_id"#,:source=> :person#, :foreign_key=>"person_id"
>
> #segments
> has_many :personSegments
> has_many :segments , :through => :personSegments
> end
>
>
> indices
>
> ThinkingSphinx::Index.define :person, :with => :active_record, :delta =>
> true do
>
> #Attributes
> has tvShows(:id), :as => :tv_show_ids
>
>
> ThinkingSphinx::Index.define :tv_show, :with => :active_record, :delta =>
> true do
>
> # attributes
> has id, :as => :tv_show_ids
> end
>
> How can i link person to tv_show?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/d/optout.