Hi JS

Your best bet for this is to add a SQL snippet to calculate that count when 
indexing:

In your index definition:

  has "COUNT(DISTICT event.id)", as: :event_count, type: :integer

Cheers

-- 
Pat

On 02/10/2013, at 2:48 PM, JS <[email protected]> wrote:

> I am wondering if you are able to order results by number of associations. 
> 
> Given a situation like this:
> 
> User:
> has_many :events, dependent: :destroy
> 
> Event:
> belongs_to :user
> 
> Is it at all possible to return users in order by the number of events they 
> have, starting with users who have the most, and ending with users who have 
> no associated event records?
> 
> I am using the following:
> rails 3.2.13
> gem 'mysql2',          '0.3.13'
> gem 'thinking-sphinx', '3.0.5'
> Using postgres (PostgreSQL) 9.2.4 as my database
> Sphinx 2.0.9-release (rel20-r4115)
> TS3
> 
> -- 
> 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/groups/opt_out.

-- 
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/groups/opt_out.

Reply via email to