Hi Andy
I think the best approach here is to create an attribute based on a SQL snippet
which returns a boolean value indicating whether users have photos or not.
has "(COUNT(photos.id) > 0)",
:as => :has_photos,
:type => :boolean
If you're not referring to the user's photos association in any of the other
fields or attributes, then you'll need to force the join - the following line
within your define_index block should do the trick:
join photos
I'm assuming photos are available via a photos association and table - adapt if
I've got it wrong.
And finally, searching is easy:
User.search 'foo', :with => {:has_photos => true}
Cheers
--
Pat
On 03/03/2011, at 6:27 AM, Andy wrote:
> I'm working on a system for managing photos, and want to search
> for users. I'd like to be able to search for only users that have
> photos
> as well as potentially search for users that specifically don't have
> photos.
>
> I've picked up a little from the docs and reading the group here, but
> frankly am kinda at a loss on where to go with it.
>
> Any insights?
>
> Thanks,
>
> Andy
>
> --
> 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.