Hi Alex

What does your finder_sql value look like?

This is a guess, but you could be able to do something like what you want by 
creating an attribute:
  join admins
  has "SQL SNIPPET", :as => :has_admin, :type => :boolean

Replace SQL SNIPPET with the actual SQL statement that returns true/false 
(PostgreSQL) or 1/0 (MySQL) as an indication of whether there is an admin.

Then in searching, you can have all objects that do have an admin before those 
that don't by ordering by that attribute before relevance weighting:

  Object.search 'foo', :order => 'has_admin DESC, @relevance DESC'

Is this what you're after?

-- 
Pat

On 02/02/2011, at 5:47 PM, alex wrote:

> Hi,
> 
> I'd like to weigh my search result with a "has_admin" (so that the
> objects that have an admin appear higher in the search results without
> an admin)
> 
> In my Object model, I have:
> 
>  has_many :admins,    :class_name   => 'User',
>                                  :finder_sql   => ' fancy SQL query
> here'
> 
> How can I write my define index (and maybe scopes?) to achieve what I
> want to build?
> 
> Thanks,
> Alex
> 
> -- 
> 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.
> 

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