FAQ
Hi,

im currently trying to understand how the standard query parser
handles operator precedence in a query like
a OR b AND c OR d
This is output by the toString method as
a +b +c d
so AND seems to have higher precedence than OR

Now if I try to check this and look at
a OR ( b AND c ) OR d
I see
a (+b +c) d
which is still fine so far, but I get a different search result.

a OR b AND C OR d matches one document that contains two tokens 'c'
one token 'b' and three tokens 'd'.
a OR (b AND c) OR d matches this document plus another one, that
contains one 'a', a number of 'b', no 'c' and no 'd'.
Token number found looking at the tokens in my input. So I might
have overseen some difference between my indexing and my token
counting.

But the question I don't understand is:
What is the difference between
a OR b AND c OR d
and
a OR ( b AND c ) OR d
or
a +b +c d
and
a (+b +c) d
Why do I get different results?

Back to my original question of operator precedence:
b AND c
gives one hit.
But
b AND c OR a AND d
(output as +b +c +a +d)
gives none.
So my theory of AND having higher precedence than OR does not hold.

Of course I should try to understand this rather from the sources than
from some experiments.
I tried, but I didn't succed.

So can anyone help me with the question how queries containing
AND OR and NOT are executed if one does not explicitly use
parentheses?

greetings
Morus

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedAug 8, '03 at 10:34a
activeAug 8, '03 at 10:34a
posts1
users1
websitelucene.apache.org

1 user in discussion

Morus Walter: 1 post

People

Translate

site design / logo © 2022 Grokbase