First of all, Solr doesn't implement strict boolean logic, see Hoss'
explanation here:
https://lucidworks.com/2011/12/28/why-not-and-or-and-not/

And bare "not" operators are a pain. There's actually _some_ trickery
_some_ places
to help you out (fq clauses come to mind) and prepend *:* for you.

I think you'll get what you expect by something like:
(*:* -someField:Foo) AND (otherField: (Bar OR Baz))

Best,
Erick

On Tue, Jul 4, 2017 at 6:04 AM, Bram Van Dam <bram.van...@intix.eu> wrote:
> Hey folks,
>
> I'm experiencing some strange query behaviour, and it isn't immediately
> clear to me why this wouldn happen. The definition of the query syntax
> on the wiki is a bit fuzzy, so my interpretation of the syntax might be off.
>
> This query does work (no results, when results are expected).
>
> (-someField:Foo) AND (otherField: (Bar OR Baz))
>
> With debug enabled, Solr interprets the query as
>
> +(-someField:Foo) +(otherField:Bar otherField:Baz)
>
> This query DOES work, results are returned.
>
> -someField:Foo +(otherField:Bar otherField:Baz)
>
> With debug enabled:
>
> -someField:Foo +(otherField:Bar otherField:Baz)
>
>
> The only difference between these queries is the presence of parantheses
> around the field with a single NOT condition. From a boolean point of
> view, they are equivalent.
>
> To make matters stranger, if I add a *:* clause to the NOT field,
> everything works again.
>
> (-someField:Foo AND *:*) AND (otherField: (Bar OR Baz))
> and
> -someField:Foo AND *:* AND (otherField: (Bar OR Baz))
> both work.
>
> Is this is query parser bug? Or are parenthesized groups with a single
> negated expression not supported? :-/
>
> I've only tested this on 5.5.4 using the default query parser, I don't
> have access to any other versions at the moment.
>
> Thanks for any insights,
>
>  - Bram

Reply via email to