You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "T. R. Halvorson" <tr...@midrivers.com> on 2010/01/19 18:00:23 UTC

Unary Operators and Operator Precedence

Here are some questions about unary operators and operator precedence or 
default order of operation.

We all know the importance of order of operation of binary operators 
(ones that operate on two operands) such as AND and OR. We know how to 
impose express order of operation by grouping and nesting.

But what about unary operators, like + (plus), the "required operator", 
and - (minus), the "prohibited operator"? Unary operators operate on 
only one operand.

Here are the questions (Leaving out of consideration for the time being 
the NOT operator which also is unary because I think we know what is 
going on with that):

1.) Does order of operation matter with unary operators?

2.) If there is operator precedence or default order of operation for 
unary operators in Lucene, is it documented or published?

3.) Does grouping or nesting affect results with unary operators? Does 
using unary operators with binary operators affect results. For example, 
in the query:

     (+a +b) OR c

has the "required" effect of the + (plus) operator been eliminated by 
the OR operator, so that nevermind whether a record contains a or 
contains b both of which supposedly are required, so long as it contains 
c, it's a hit?

T. R.

trh@midrivers.com
www.linkedin.com/in/trhalvorson
www.ncodian.com
http://twitter.com/trhalvorson 


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Unary Operators and Operator Precedence

Posted by Marvin Humphrey <ma...@rectangular.com>.
> 3.) Does grouping or nesting affect results with unary operators? Does 
> using unary operators with binary operators affect results. For example, 
> in the query:
> 
>     (+a +b) OR c
> 
> has the "required" effect of the + (plus) operator been eliminated by 
> the OR operator, so that nevermind whether a record contains a or 
> contains b both of which supposedly are required, so long as it contains 
> c, it's a hit?

IMO, that's the only sensible way to handle unary operators.  If they were
global rather than nested, what would this query produce?

   (a AND -b) OR (b AND c)

Marvin Humphrey


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Unary Operators and Operator Precedence

Posted by Ahmet Arslan <io...@yahoo.com>.
> Here are some questions about unary
> operators and operator precedence or default order of
> operation.
> 
> We all know the importance of order of operation of binary
> operators (ones that operate on two operands) such as AND
> and OR. We know how to impose express order of operation by
> grouping and nesting.
> 
> But what about unary operators, like + (plus), the
> "required operator", and - (minus), the "prohibited
> operator"? Unary operators operate on only one operand.

You might find this link interesting.

http://wiki.apache.org/lucene-java/BooleanQuerySyntax


      

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org