lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <>
Subject query parser operator precedence and strange result
Date Fri, 08 Aug 2003 10:33:39 GMT

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

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

Back to my original question of operator precedence:
b AND c
gives one hit.
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 


View raw message