Skip to content

Logic

For the complete documentation index see: llms.txt

All documentation pages available in markdown.

Logic expressions combine Boolean subexpressions with and, or, not, and exclusive (Database 5.6.0 and later). Each evaluates to a Boolean, so they go wherever a Boolean is required: a record filter on a single-record, batch, scan or query command, an XDR filter, a cond branch, and the filter contexts of path expressions. They occupy the same place as comparison expressions, and most often take comparisons as their operands.

and, or, and not follow trilean rules when an operand can be unknown — during the metadata-only phase of evaluation, for instance. or evaluates to true as soon as one operand is true, even when another is unknown. exclusive tests whether exactly one of its operands is true. For how true, false, and unknown interact otherwise, see the execution model and unknown.

Path expressions

and and or appear often inside path expression filter contexts such as allChildrenWithFilter and andFilter. See combining multiple filters in the path advanced guide.

The bookstore example on the path overview nests eq and lt on loop variables inside an and — typical of real document-style filters.

The Developer SDK’s AEL text syntax expresses the same logic inline, for example $.age > 21 and $.status == 'active'.

Each operation’s Example shows the code in nine tabs: Aerospike Expression Language (AEL) text on the Java SDK and Python SDK tabs, and the Exp builder on the other seven. See the AEL reference for AEL grammar.

Ops

and

and(arg0, arg1, ...)
Description

Returns false if any argument is false, true if every argument is true, and unknown otherwise (an argument is unknown and none is false).

Arguments
NameTypeDescription
arg0boolean

First condition.

arg1boolean

Second condition.

...boolean

Any further conditions.

Returns
boolean
Introduced
5.2.0.4
Example

Find records that have a stored user key and that key is an integer less than 1000 (metadata + key comparison). For the same combinator on nested bins inside path filters, see the bookstore example.

String exp = "$.keyExists() and $.key() < 1000";

exclusive

exclusive(arg0, arg1, ...)
Description

Returns true if exactly one argument is true, and false if none or more than one is. Arguments are evaluated in order: an unknown argument makes the result unknown, unless two arguments before it are already true. Useful for testing whether several conditions are mutually exclusive.

Arguments
NameTypeDescription
arg0boolean

First condition.

arg1boolean

Second condition.

...boolean

Any further conditions.

Returns
boolean
Introduced
5.6.0
Example

Find records where exactly one of these is true: string bin hand is hook, leg is peg, or pet is parrot. (Illustrates mutual-exclusion checks on independent bins—not nested path logic.)

String exp = "exclusive($.hand == 'hook', $.leg == 'peg', $.pet == 'parrot')";

not

not(arg)
Description

Returns true if arg is false, false if arg is true, and unknown if arg is unknown.

Arguments
NameTypeDescription
argboolean

Condition to negate.

Returns
boolean
Introduced
5.2.0.4
Example

Find records that do not have the primary key stored in record metadata (keyExists is false).

String exp = "not($.keyExists())";

or

or(arg0, arg1, ...)
Description

Returns true if any argument is true, false if every argument is false, and unknown otherwise (an argument is unknown and none is true).

Arguments
NameTypeDescription
arg0boolean

First condition.

arg1boolean

Second condition.

...boolean

Any further conditions.

Returns
boolean
Introduced
5.2.0.4
Example

Find records where string bin country is either US or CA (same “one of several string values” idea as the expression index tutorial, which uses Or / Eq for target countries in Python).

String exp = "$.country == 'US' or $.country == 'CA'";