Operator precedence
A text search server supports the logical operators NOT, AND, and OR. These operators have normal precedence.
The NOT operator binds stronger than the AND operator, which binds
stronger than the OR operator. For example, a OR NOT b AND
c
is equivalent to (a OR ((NOT b) AND c)
.
An operator binds only the terms that immediately precede or follow
it.
In the absence of a logical operator, each term is
processed as a required term. For example, a b
is
treated like +a +b
.
All other operators bind stronger than logical operators, but logical
operators bind stronger than no operators. For example, the query a
b OR c
is equivalent to +a +(b OR c)
.
The modifiers +, -, and ? bind stronger than any other operators.
The modifier + makes a term required; whereas, the modifier - excludes
a term in a search. The modifier ? makes a term optional. Therefore,
the query a -b ?c
returns all documents that contain a
,
but do not contain b
. If a document also contains c
,
that document will get a higher score, but c
is not
required.