- Previous: News API Versions
- Up: News API Versions
- Next: News API v1 Documentation
Query Grammar
Grammar
Query | Example | Description |
---|---|---|
any terms |
|
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 . |
" " |
|
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 |
|
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 |
|
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 |
|
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)
- Previous: News API Versions
- Up: News API Versions
- Next: News API v1 Documentation
Docs Navigation
- Documentation
- API Notes
- Sport
- News API Versions
- Cricket
- API Notes
- Release Notes
- API Data Dictionary - Dismissal Types
- API Data Dictionary - Match Statuses
- API Data Dictionary - Match Types
- API Data Dictionary - Result Types
- API Data Dictionary - Result Win Types
- API Data Dictionary - Official Types
- API Data Dictionary - Toss Win Type
- API Data Dictionary - Bowling Types
- API Data Dictionary - Batting Types
- API Data Dictionary - Statistic Types
- TV API
- Football
- Olympics
- Olympics API Version 1
- Olympics API Version 2
- Release Notes
- API Notes
- API Data Dictionary - Event Units
- API Data Dictionary - Standings
- API Data Dictionary - Olympic Result Extensions
- API Data Dictionary - Olympic Result Properties
- API Data Dictionary - Paralympic Result Extensions
- API Data Dictionary - Paralympic Result Properties
- API Data Dictionary - Commonwealth Result Extensions
- API Data Dictionary - Commonwealth Result Properties
- API Data Dictionary - Brackets