Precedence and Parentheses
The Internet Style mode operators '+' and '-' take precedence
over the other search operators. For example, +big dog <order>
cat matches all documents that contain the term big, boosting
the ranking of any documents that contain any of the three terms dog,
or cat.
Within query operators mode, the operators
have the following precedence classes, from greatest to least:
- NEAR, ORDER, PHRASE, SENTENCE, PARAGRAPH
- NOT
- AND
- OR
Parentheses can be used to override operator precedence.
The following two queries are equivalent (the parentheses do not effect
the semantics of the search).
- a and b near c or d
- (a and (b near c)) or d
This search matches documents that meet one of two conditions:
- The document contains the term d
- The document contains the terms a, b, and c, with b and c in close
proximity
On the other hand, the parentheses in the following query
override the default operator precedence:
a and b near (c or d)
This search matches documents containing the terms a and b
and either c or d, where b is in close proximity to c or d.