This sounds vaguely familiar...

I think it's because you're using the same table name/alias in your  
conditions for both associations, and yet Sphinx will need to join  
twice on that table (and thus one will have a different alias). As for  
a way around this, I'm not really sure... does ActiveRecord play  
nicely with a hash instead of a string for those conditions?

ie: :conditions => {:relationship => 'Homeclub'}

-- 
Pat

On 10/11/2009, at 2:40 AM, ACTRAiSER wrote:

>
> Hi,
>
> another special edge case (probably) to solve:
>
> I have a user-model with sportsclub-relations were people can add
> their home-sportsclub as well as favourite sportsclubs.
>
> In my user model i use:
>
>  has_many :homeclubs, :class_name => 'ClubUserRelation', :conditions
> => "club_user_relations.relationship = 'Homeclub'"
>  has_many :favourite_clubs, :class_name =>
> 'ClubUserRelation', :conditions => "club_user_relations.relationship =
> 'Favourite'"
>
> in my sphinx index is use
>
> define_index do
>    has homeclubs(:club_id), :as => :homeclub_ids, :type => :integer
>    has favourite_clubs(:club_id), :as => :favourite_club_ids, :type
> => :integer
> end
>
> Now i want to search for Users who have the sportsclub with id 1 as
> their homeclub, and in a second search i want to find users with the
> same club but as favourite. The problem is, that only the first Search
> works (homeclub in this case).
>
> User.search("",:with => {:homeclub_ids => 1 }) => works
> User.search("",:with => {:favourite_club_ids => 1 }) => No results
>
>
> If i exchange the rows in the define_index block, then the
> favourite_club-search works but not the homeclub.
>
> define_index do
>    has favourite_clubs(:club_id), :as => :favourite_club_ids, :type
> => :integer
>    has homeclubs(:club_id), :as => :homeclub_ids, :type => :integer
> end
>
> User.search("",:with => {:homeclub_ids => 1 }) => No results
> User.search("",:with => {:favourite_club_ids => 1 }) => Works
>
> Does anyone know why this problem occurs? It may have something to do
> that i use the class_name "ClubUserRelation" in both has_many-
> associations, i am not sure, nor am i sure if this is a ts-problem or
> a design-problem on my side.
>
> Greets
> -act
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to