The
Java and Python OJAI clients support a
QueryCondition interface. After you create a QueryCondition
object, call methods in the class to construct your query condition.
QueryCondition ObjectJava OJAI provides a QueryCondition.is() method for specifying query
conditions. The method takes three arguments:
QueryCondition.OpThe field path is either a field in a JSON document, a subfield within a nested document, or an array element.
Depending on the type of the field path, you specify the comparison value as follows:
int, float, or String) or a
Java OJAI object. The API supports the following OJAI types:ODateOIntervalOTimeOTimestampMap object. In the
case of equality, all of the fields in the nested document must match. The order
of the fields is not relevant.List object. In the case of equality, the
order of the elements and the element values must match. In addition to QueryCondition.is(), QueryCondition
also supports the following methods:
QueryCondition Method |
Description |
|---|---|
equals()
|
Match for equality or non-equality on nested documents and arrays |
in()
|
Search for individual elements in an array |
like() |
Search for string values using SQL LIKE expressions |
|
|
Search for string values using regular expressions. 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 |
and() |
Begins a new AND condition block |
or() |
Begins a new OR condition block |
elementAnd() |
Begins a new elementAnd block. See OJAI Query Condition Operators for a
detailed description of this operator. |
close() |
Closes a compound condition block |
build() |
Builds the condition |
QueryCondition API. It introduces you to the basics of the API. For
the complete API, see the QueryCondition interface.Python OJAI provides a QueryCondition.is_() method for specifying
query conditions. The method takes three arguments:
QueryConditionOpThe field path is either a field in a JSON document, a sub-field within a nested document, or an array element. Starting in MapR 6.1, you can also specify a container field path. See OJAI Query Conditions Using Container Field Paths for details.
Depending on the type of the field path, you specify the comparison value as follows:
int, float, or str) or a
Python OJAI object. The API supports the following OJAI types:ODateOIntervalOTimeOTimestampdictionary object.
In the case of equality, all of the fields in the nested document must match. The
order of the fields is not relevant.list object. In the case of equality, the
order of the elements and the element values must match. In addition to QueryCondition.is_(), QueryCondition
also supports the following methods:
QueryCondition Method |
Description |
|---|---|
equals_()
|
Match for equality or non-equality on nested documents and arrays |
in_()
|
Search for individual elements in an array |
like_() |
Search for string values using SQL LIKE expressions |
|
|
Search for string values using regular expressions. You can use regular expressions that comprise the Perl-Compatible Regular
Expressions (PCRE) library as well as a subset of the regular expressions
that are supported in |
and_() |
Begins a new AND condition block |
or_() |
Begins a new OR condition block |
element_and() |
Begins a new |
close() |
Closes a compound condition block |
build() |
Builds the condition |
QueryCondition API. It introduces you to the basics of the API.
For the complete API, see the QueryCondition
interface.C# OJAI provides a QueryCondition.ls() method for specifying query
conditions. The method takes three arguments:
QueryOpThe field path is either a field in a JSON document, a sub-field within a nested document, or an array element. Starting in MapR 6.1, you can also specify a container field path. For details, see OJAI Query Conditions Using Container Field Paths.
Depending on the type of the field path, you specify the comparison value as follows:
int, float, or string) or a
C# OJAI object. The API supports the following OJAI types:OjaiDateOjaiIntervalOjaiTimeOjaiTimestamplist of values of the specified type. In the
case of equality, the order of the elements and the element values must match.
In addition to QueryCondition.ls(), QueryCondition
also supports the following methods:
QueryCondition Method |
Description |
|---|---|
Condition() |
Search for values using a specific condition. |
Equals()
|
Match for equality or non-equality on nested documents and arrays. |
Exists()
|
Search for a field if the given field path exists, or verify that a field path does not exist. |
In()
|
Search for individual elements in an array or verify their absence. |
Like()
|
Search for string values using SQL LIKE expressions or verify they do not match the specified SQL LIKE expression. |
|
|
Search for string values using regular expressions. You can use regular expressions that comprise the Perl-Compatible Regular
Expressions (PCRE) library, as well as a subset of the regular expressions
that are supported in |
SizeOf() |
Search for a value of the specified size. The value must be one of the
following types:
|
|
|
Search for value of the specified Type or verify its absence. |
And() |
Begins a new AND condition block. |
Or() |
Begins a new OR condition block. |
ElementAnd() |
Begins a new |
Close() |
Closes a compound condition block. |
Build() |
Builds the condition. |
Go OJAI provides a QueryCondition.ls() function for specifying query
conditions. The function takes three arguments:
QueryOpThe field path is either a field in a JSON document, a sub-field within a nested document, or an array element. Starting in MapR 6.1, you can also specify a container field path. For details, see OJAI Query Conditions Using Container Field Paths.
Depending on the type of the field path, you specify the comparison value as follows:
int, float64, or string) or a
Go OJAI object. The API supports the following OJAI types:OjaiDateOjaiTimeOjaiTimestamplist of values of the specified type. In the
case of equality, the order of the elements and the element values must match.
In addition to QueryCondition.ls(), QueryCondition
also supports the following functions:
QueryCondition Function |
Description |
|---|---|
|
|
Search for values using a specific condition. |
Equals()
|
Match for equality or non-equality on nested documents and arrays. |
Exists()
|
Search for a field if the given field path exists, or verify that it does not exist. |
In()
|
Search for individual elements in an array or verify their absence. |
Like()
|
Search for string values using SQL LIKE expressions or verify they do not match the specified SQL LIKE expression. |
|
|
Search for string values using regular expressions. You can use regular expressions that comprise the Perl-Compatible Regular
Expressions (PCRE) library, as well as a subset of the regular expressions
that are supported in |
|
|
Search for value of the specified Type or verify its absence. |
And() |
Begins a new AND condition block. |
Or() |
Begins a new OR condition block. |
ElementAnd() |
Begins a new |
Close() |
Closes a compound condition block. |
Build() |
Builds the condition. |
Query
API. It introduces you to the basics of the API. For the complete API, see the
Query interface.QueryCondition Object The following example shows how to define a QueryCondition object for this
query condition:
(a.b.[0].boolean == false && (a.c.d != 5 || a.b[1].decimal > 1 || a.b[1].decimal < 10))
QueryCondition qc = connection.newCondition()
.and()
.is("a.b[0].boolean", Op.EQUAL, false)
.or()
.is("a.c.d", Op.NOT_EQUAL, 5)
.is("a.b[1].decimal", Op.GREATER, 1)
.is("a.b[1].decimal", Op.LESS, 10)
.close()
.close()
.build();
Pass the QueryCondition object to the Query.where method. For a complete Java code example, see the
Java - OJAI QueryCondition Object example at Querying with Conditions.
qc = connection.new_condition()
.and_()
.is_('a.b[0].boolean', QueryConditionOp.EQUAL, False)
.or_()
.is_('a.c.d', QueryConditionOp.NOT_EQUAL, 5)
.is_('a.b[1].decimal', QueryConditionOp.GREATER, 1)
.is_('a.b[1].decimal', QueryConditionOp.LESS, 10)
.close()
.close()
.build()
Pass the QueryCondition object to the Query.where method. For a complete Python code example, see the
Python - OJAI QueryCondition Object example at Querying with Conditions.
var condition = connection.NewQueryCondition()
.And()
.Is("a.b[0].boolean", QueryOp.EQUAL, false)
.Or()
.Is("a.c.d", QueryOp.NOT_EQUAL, 5)
.Is("a.b[1].decimal", QueryOp.GREATER, 1)
.Is("a.b[1].decimal", QueryOp.LESS, 10)
.Close()
.Close()
.Build();
Pass the Condition object to the Query.Where
method. For a complete C# code example, see the C# - OJAI QueryCondition Object
example at Querying with Conditions.
condition, err := client.MakeCondition( client.And(), client.Is("a.b[0].boolean", client.EQUAL, false), client.Or(), client.Is("a.c.d", client.NOT_EQUAL, 5), client.Is("a.b[1].decimal", client.GREATER, 1), client.Is("a.b[1].decimal", client.LESS, 10), client.Close(), client.Close()) condition.Build()
Pass the Condition object to the
Query.WhereCondition function. For
a complete Go code example, see the Go - OJAI QueryCondition Object example at
Querying with Conditions.
QueryCondition.elementAnd MethodThe following example shows how to write the elementAnd condition
described at Using elementAnd with Nested Documents, using a QueryCondition object:
QueryCondition qc = connection.newCondition()
.elementAnd("grades[]")
.is("course", QueryConditionOp.EQUALS, "history")
.is("score", QueryConditionOp.EQUALS, 12)
.close()
.build();
qc = connection.new_condition()
.element_and("grades[]")
.is_("course", QueryConditionOp.EQUALS, "history")
.is_("score", QueryConditionOp.EQUALS, 12)
.close()
.build()
var condition = connection.NewQueryCondition()
.ElementAnd("grades[]")
.Is("course", QueryOp.EQUALS, "history")
.Is("score", QueryOp.EQUALS, 12)
.Close()
.Build();
condition, err := client.MakeCondition( client.ElementAnd("grades[]"), client.Is("course", client.EQUAL, "history"), client.Is("score", client.EQUAL, 12), client.Close()) condition.Build()
The following code corresponds to the example described at Using elementAnd with Scalar Values using a
QueryCondition object:
QueryCondition qc = connection.newCondition()
.elementAnd("values[]")
.is("$", QueryConditionOp.GREATER, 7)
.is("$", QueryConditionOp.LESS, 14)
.close()
.build();
qc = connection.new_condition()
.element_and("values[]")
.is_("$", QueryConditionOp.GREATER, 7)
.is_("$", QueryConditionOp.LESS, 14)
.close()
.build()
var condition = connection.NewQueryCondition()
.EementAnd("values[]")
.Is("$", QueryOp.GREATER, 7)
.Is("$", QueryOp.LESS, 14)
.Close()
.Build();
condition, err := client.MakeCondition( client.ElementAnd("values[]"), client.Is("$", client.EQUAL, 7), client.Is("$", client.EQUAL, 14), client.Close()) condition.Build()