• Register

Query Grammar

Grammar

QueryExampleDescription
any terms

dog

dog cat

Match one or more terms. Adjacent terms and phrases are implicitly joined with AND. For example, dog cat is the same as dog AND cat.
" "

"dog tail"

"dog tail" "cat whisker"

dog "cat whisker"

Terms in double quotes are treated as a phrase. Adjacent terms and phrases are implicitly joined with AND. For example, dog "cat whisker" matches documents containing both the term dog and the phrase cat whisker.
( ) (cat OR dog) zebra Parentheses indicate grouping. The example matches documents containing at least one of the terms cat or dog, and also contain the term zebra.
-query

-dog

-(dog OR cat)

cat -dog

A NOT operation. For example, cat -dog matches documents that contain the term cat but that do not contain the term dog.
query1 AND query2

dog AND cat

(cat OR dog) AND zebra

Match two query expressions. For example, dog AND cat matches documents containing both the term dog and the term cat. AND is the default way to combine terms and phrases, so the previous example is equivalent to dog cat.
query1 OR query2 dog OR cat Match either of two queries. The example matches documents containing at least one of either of terms cat or dog.
query1 NOT_IN query2 dog NOT_IN "dog house" Match one query when the match does not overlap with another. The example matches occurrences of dog when it is not in the phrase dog house.
query1 NEAR query2

dog NEAR cat

(cat food) NEAR mouse

Find documents containing matches to the queries on either side of the NEAR operator when the matches occur within 10 terms of each other. For example, dog NEAR cat matches documents containing dog within 10 terms of cat.
query1 NEAR/N query2 dog NEAR/2 cat Find documents containing matches to the queries on either side of the NEAR operator when the matches occur within N terms of each other. The example matches documents where the term dog occurs within 2 terms of the term cat.
query1 BOOST query2 george BOOST washington Find documents that match query1. Boost the relevance score of documents that also match query2. The example returns all matches for the term george, with matches in documents that also contain washington having a higher relevance score.

 

Operator Precedence

The precedence of operators, from highest to lowest, is shown in the following table. Each row in the table represents a precedence level. Where multiple operators have the same precedence, evaluation occurs from left to right. Query sub-expressions using operators higher in the table are evaluated before sub-expressions using operators lower in the table.

-
NOT_IN
BOOST
( ), NEAR, NEAR/N
AND
OR

For example, AND has higher precedence than OR, so the following queries:

A AND B OR C
A OR B AND C

Evaluate as if written as follows:

(A AND B) OR C
A OR (B AND C)

Docs Navigation