Deep association and Sphinx index with Thinking Sphinx?
Currently I have the ff table:
Teams id Team_User team_id, user_id Users user_id Item id team_id
And the ff. model:
Team has_and_belongs_to_many :users User has_and_belongs_to_many :teams Item belongs_to :audit_team, :class_name => "Team", :foreign_key => "team_id"
Why I am trying to archive is to get Sphinx to index all the user_id that associate with Item and I came up with this index definition:
define_index do has audit_team.users(id), :as => :team_users end
I am not sure if this is correct or not. Also it's seam that Thinking Sphinx didn't build the config for this. As I rebuild, reindex and run the app, the ff. error shows up:
index ncpar_core: no such filter attribute 'team_users'
What could be the problem and how can I archive this?
Thank you very much
You may need to run ts:rebuild after adding the attribute so Sphinx is aware of it. Also, perhaps it's a typo here instead of in your code, but id in the attribute definition should be a symbol:
has audit_team.users(:id), :as => :team_users