This definitely looks cleaner but has the disadvantage of introducing
another "field"... I want my end users to write their own search
queries like "title: Brown fox owned_by: John Doe color: blue" etc.

On Sep 8, 3:22 pm, James Healy <[email protected]> wrote:
> Greg wrote:
> > One way to get what I want:
>
> > define_index do
> >   indexes title
> >    ...
> >   indexes "IF(ISNULL(owner_id),'nobody',concat_ws(' ',
> > users.first_name, users.last_name))", :as => :owner_or_nil
> > end
>
> > But this seems very nasty, is there a more elegant approach?
>
> I would solve this with attributes:
>
>   define_index do
>     ...
>     indexes title
>     indexes [first_name, last_name], :as => :owner
>     ...
>     has owner_id, :type => :integer
>   end
>
> Null values get converted to 0 when stored as an int attribute in a
> sphinx index, so filtering by owner_id of 0 should get what you want.
>
>   Product.search(:with => {:owner_id => 0})
>
> -- James Healy <jimmy-at-deefa-dot-com>  Wed, 09 Sep 2009 00:18:13 +1000
--~--~---------~--~----~------------~-------~--~----~
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