! operator

1 view
Skip to first unread message

Josh

unread,
Feb 2, 2008, 2:04:14 AM2/2/08
to ambition.rb
Is there anyway to support a ! operator? I've been working on the
sphinx adapter, and say we want to do a query like:

'dog OR cat OR "white tigers" NOT (lions OR bears) AND
title:animals'

This is how I'd expect to do it in ruby:

Tweet.select{ |t| ("dog" || "cat" || "white tiger") && ( ("lions"
|| "bears") && t.title == "animals") }

The only negation I see happening in the not_regexp and not_equals,
but that doesn't really work out so well here.

I think part of the problem here is that with sphinx, you can search
for terms not on a specific field. So, "dog" would be searched for
under any of the indexed attributes.

Chris Wanstrath

unread,
Feb 2, 2008, 4:49:09 AM2/2/08
to ambit...@googlegroups.com
On 2/1/08, Josh <joshua....@gmail.com> wrote:

> Is there anyway to support a ! operator? I've been working on the
> sphinx adapter, and say we want to do a query like:
>
> 'dog OR cat OR "white tigers" NOT (lions OR bears) AND
> title:animals'
>
> This is how I'd expect to do it in ruby:
>
> Tweet.select{ |t| ("dog" || "cat" || "white tiger") && ( ("lions"
> || "bears") && t.title == "animals") }

There's no bang (!) in that, which I assume is a typo. I would not
map the above Ruby to mean "not lions or bears" if I were translating
it to English. Or am I overlooking something?

--
Chris Wanstrath
http://errfree.com // http://errtheblog.com
http://github.com // http://famspam.com

Josh

unread,
Feb 2, 2008, 12:07:13 PM2/2/08
to ambition.rb
Whoops, I removed the ! at some point, and forgot to add it back.

Tweet.select{ |t| ("dog" || "cat" || "white tiger") && (!("lions"
|| "bears") && t.title == "animals") }



On Feb 2, 4:49 am, "Chris Wanstrath" <ch...@ozmm.org> wrote:

Chris Wanstrath

unread,
Feb 16, 2008, 6:53:32 AM2/16/08
to ambit...@googlegroups.com
I made a change tonight that makes the `negated` method available to
translators. It is 'true' if the method being run is inside a !().
Let me know if that helps at all.

Reply all
Reply to author
Forward
0 new messages