OJAI Query Condition Operators
OJAI supports comparison, existence, between, match, like, type of, size of, in, and logical operators.
Click the name in the following box to navigate to the section that provides details on each operator.
Comparison Operators
- Operators
-
Operator Syntax Equals {"$eq":{"fieldpath":value}}
Greater Than {"$gt":{"fieldpath":value}}
Greater Than or Equals {"$ge":{"fieldpath":value}}
Less Than {"$lt":{"fieldpath":value}}
Less Than or Equals {"$le":{"fieldpath":value}}
Not Equals {"$ne":{"fieldpath":value}}
- Description
-
Compares the data in
fieldpath
againstvalue
for the specified operator.Float and double data are approximate representations of decimal values. They may not return true in equality comparisons against their equivalent decimal values.
You can specify only equality and non-equality conditions on nested documents and arrays.
In the case of equality on nested documents, all of the fields in the nested document must match. The order of the fields is not relevant.
In the case of equality on arrays, both the order of the elements and the element values must match.
Existence Operators
- Exists
-
- Syntax
-
{"$exists":"fieldpath"}
- Description
Checks for existence of
fieldpath
.
- Not Exists
-
- Syntax
-
{"$notexists":"fieldpath"}
- Description
Checks for non-existence of
fieldpath
.
See Existence Conditions with Container Field Paths for details about how these operators behave when you use them with container field paths.
Between
- Syntax
-
{"$between":{"fieldpath":[startValue,endValue]}}
- Description
-
Checks if the value in
fieldpath
is in the range specified bystartValue
andendValue
, where the values are inclusive.
Matches Operators
- Operators
-
Operator Syntax Matches {"$matches":{"fieldpath":matchValue}}
Not Matches {"$notmatches":{"fieldpath":matchValue}}
- Description
-
Performs a regular expression match on
fieldPath
usingmatchValue
.You can use regular expressions that compose the Perl-Compatible Regular Expressions (PCRE) library as well as a subset of the regular expressions that are supported in
java.util.regex.pattern
. See HBase Java Regular Expressions Support for a list of supported regular expressions.
Like Operators
- Operators
-
Operator Syntax Like {"$like":{"fieldpath":likeValue}}
Not Like {"$notlike":{"fieldpath":likeValue}}
- Description
-
Performs a SQL LIKE comparison on
fieldPath
wherelikeValue
is a string with wildcard characters '%' and '_'. - Special-Purpose Characters for the Like Operators
- The OJAI API allows you to use four special-purpose characters or patterns with
$like
operator expressions:Special-Purpose Character Description Example %
Matches any string of zero or more characters. "abc%"
matches"abc"
,"abcd"
,"abcde232136"
, etc."%abc"
matches"abc"
,"pqrabc"
, etc._
Matches a single character. "_am"
matches"ram"
,"sam"
,"Sam"
,"cam"
.[]
Matches a single character in the specified set or range. "[r-t]am"
matches"ram"
,"sam"
, and"tam"
but not"Sam"
or"cam"
.[^]
Matches a single character not in the specified set or range. "[^r-t]am"
matches"Sam"
,"pam"
,"jam"
, or"cam"
but not"ram"
,"sam"
and"tam"
.
Type of Operators
- Type Of
-
- Syntax
-
{"$typeof":{"fieldpath":"typeValue"}}
- Description
-
Checks whether
fieldpath
is of typetypeValue
.
- Not Type Of
-
- Syntax
-
{"$nottypeof":{"fieldpath":"typeValue"}}
- Description
-
Checks whether
fieldpath
is not of typetypeValue
.typeValue
can be any ofmap
,array
,binary
,date
,time
,timestamp
,interval
,double
,float
,long
,int
,short
,byte
,string
,boolean
, ornull
.
Size Of
- Syntax
-
{"$sizeof":{"fieldpath":{"comparisonOp":intValue}}}
- Description
-
Compares the size of the data in
fieldpath
againstintValue
, usingcomparisonOp
. The size varies depending on the type offieldPath
:- String
- Length of string
- Array
- Number of elements in the array
- Nested document
- Number of subfields in the nested document
comparisonOp
can be any of$eq
,$lt
,$le
,$gt
,$ge
, or$ne
.
In Operators
- In
-
- Syntax
-
{"$in":{"fieldpath":inOpValues}}
- Description
-
Checks whether the data in
fieldpath
is in the list specified byinOpValues
.
- Not In
-
- Syntax
-
{"$notin":{"fieldpath":inOpValues}}
- Description
-
Checks whether the data in
fieldpath
is not in the list specified byinOpValues
Logical Operators
- And
-
- Syntax
-
{"$and":[OJAIQueryConditions]}
- Description
-
Applies logical AND on a list of conditions.
OJAIQueryConditions
is a comma-separated list of OJAI query conditions.
- Or
-
- Syntax
-
{"$or":[OJAIQueryConditions]}
- Description
-
Applies logical OR on a list of conditions.
OJAIQueryConditions
is a comma-separated list of OJAI query conditions.
- Element And
-
- Syntax
-
{ "$elementAnd":{ "containerFieldPath": [OJAIQueryConditions] } }
NOTESupported starting in MapR 6.1. - Description
-
Applies multiple conditions as part of a group. All conditions must be true for a common array element.
OJAIQueryConditions
is the comma-separated list of the OJAI query conditions.containerFieldPath
exhibits the following behaviors:containerFieldPath
specifies the container path prefix of the common container element.- If
containerFieldPath
refers to a container of nested documents, then you must use field paths relative to the common prefix in yourOJAIQueryConditions
. - If the
containerFieldPath
refers to a container of scalar values, then you use the$
symbol to refer to individual elements in yourOJAIQueryConditions
.
NOTEThere is noelementOr
operator because it is semantically equivalent to an OR operator.