| |||||||||||||||||||||
You can use the Boolean operators AND, OR, and NOT in your searches.
When you use the NEAR operator in a query, a document matches the query if the words are within 50 words of each other in the document. The closer together the words are, the higher the rank that is assigned to the document in the result set. If the words are more than 50 words apart, they are not considered near enough, and the document is assigned a rank of zero. The NEAR operator can be applied only to words or phrases.
In content queries, use the NOT operator only after the AND operator. Use the NOT operator only to exclude documents that match a previous content restriction. For property-value queries, the NOT operator can be used apart from the AND operator.
The following table explains the Boolean operators and their associated symbols.
| Operator | Long form | Short form |
|---|---|---|
| AND | AND | & |
| OR | OR | | |
| NOT | AND NOT | &! |
| NEAR | NEAR | Near, ~ |
The following table shows some examples of the use of Boolean operators:
| To search for | Long form | Short form | Result |
|---|---|---|---|
| Two terms in the same document | red and dog | red & dog | Documents with both the words "red" and "dog" |
| Either of two terms in a document | red or dog | red | dog | Documents with the words "red" or "dog" |
| One term without a second term | red and not dog | red & ! dog | Documents with the word "red" but not "dog" |
| Documents not matching a property value | not {prop name=size} = 100 | !@size = 100 | Documents that are not 100 bytes |
| Two terms that are close together in the same document | red near dog | red ~ dog | Documents with the word "red" near the word "dog" |
| Either of two terms and not two other terms if they are close together | red or dog and not (black near cat) | red | dog &! (black~cat) | Documents with the word "red" or "dog" and not the words "black" and "cat" if they are within 50 words of each other |
Note
Order of precedence rules
Boolean operators are evaluated in the following order:
After precedence rules are applied, operators are processed left to right. You can use parentheses (( )) to override the normal precedence. For example, the first three queries are equivalent, but the fourth is not:
a AND b OR c
c OR a AND b
c OR (a AND b)
(c OR a) AND b
In the fourth query, the OR operator is evaluated first because the expression is enclosed in parentheses.
©1997-2012, Logitree Inc. |