Comparison Clause (Reference)
The script content on this page is for navigation purposes only and does not alter the content in any way.
A comparison clause is an object member whose field is a comparison operator. Example: "$gt" : 200.
Table 5-1 describes the comparison operators. See Sample JSON Documents for the documents used in the examples in column Description.
Table 1 Filter Comparison Operators
| Operator | Description |
|---|---|
$exists |
Tests whether the field exists. Matches document if either:
Operand JSON scalar. Example matches sample document 3. matches sample documents 1 and 2. |
$eq |
Matches document only if field value equals operand value. Operand JSON scalar. Example matches sample document 1. |
$ne |
Matches document only if field value does not equal operand value or there is no such field in the document. Operand JSON scalar. Example matches sample documents 2 and 3. |
$gt |
Matches document only if field value is greater than operand value. Operand JSON number or string. Example matches sample document 2. |
$lt |
Matches document only if field value is less than operand value. Operand JSON number or string. Example matches sample document 1. |
$gte |
Matches document only if field value is greater than or equal to operand value. Operand JSON number or string. Example matches sample documents 1, 2, and 3. |
$lte |
Matches document only if field value is less than or equal to operand value. Operand JSON number or string. Example matches sample document 1. |
$between |
Matches document only if string or number field value is between the two operand array elements or equal to one of them. Operand JSON array of two scalar elements. The first must be the smaller of the two. (For string values, smaller means first, lexicographically.) At most one of the elements can be Example matches sample documents 2 and 3. matches sample documents 1, 2, and 3. It is equivalent to |
$startsWith |
Matches document only if field value starts with operand value. Operand JSON string. Example matches sample document 1. |
$hasSubstring or $instr |
Matches document only if field value is a string with a substring equal to the operand. Operand Non-empty JSON string. Example matches sample documents 1 and 2. |
$regex |
Matches document only if field value matches operand regular expression. Operand SQL regular expression, as a JSON string. See [Oracle Database SQL Language Reference](/pls/topic/lookup?ctx=en/database/oracle/simple-oracle-document-access/adsdi&id=SQLRF020). Example matches sample document 1. |
$like |
Matches document only if field value matches operand pattern. Operand SQL See [Oracle Database SQL Language Reference](/pls/topic/lookup?ctx=en/database/oracle/simple-oracle-document-access/adsdi&id=SQLRF-GUID-0779657B-06A8-441F-90C5-044B47862A0A). Example matches sample documents 2 and 3. |
$in |
Matches document only if field exists and its value equals at least one value in the operand array. Operand Non-empty JSON array of scalars.[^1] Example matches sample documents 1 and 2. |
$nin |
Matches document only if one of these is true:
Operand Non-empty JSON array of scalars.[^1] Example matches sample documents 1 and 2. |
$all |
Matches document only if one of these is true:
Operand Non-empty JSON array of scalars.[^1] Example matches sample document 2. matches sample documents 1 and 2. |
Related Topics