I have a model that includes the follow two associations:
class Constituent
has_many :involved_sponsorships, :class_name => "Sponsorship",
:foreign_key => "paying_constituent_id"
has_many :sponsorships
The related Sponsorships model includes the following two relationships:
class Sponsorship
belongs_to :constituent
belongs_to :paying_constituent, :class_name => "Constituent",
:foreign_key => "paying_constituent_id"
---
I need to create an index that will allow me to search based on a count of
sponsorships, BUT sponsorships in this context needs to include the total
quantity of BOTH the involved_sponsorships association and the sponsorships
association.
I know I can create the following filter which will count ONLY the
sponsorships associations:
has 'COUNT(sponsorships.id)', :as => :sponsorship_count, :type => :integer
I'm struggling to find a summary of how I might structure the custom SQL
here in the index to essentially handle joining the sponsorships count to
the involved_sponsorships count and index that as the :sponsorship_count
Hard to imagine this isn't something anybody else has tried to tackle but
I've come up fairly empty-handed in all my searches for a comparable
situation or example. On a related note, is there any documentation
specifically about the custom SQL syntax available in building these
indexes? Thanks for any help anybody is able to provide!
--
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.