Value Types and Operators

ReQL supports the following value types:

  • int – signed integer (currently 64bit),
  • double – double-precision floating-point number (IEEE 754 compliant),
  • timestamp – UTC timestamp, similar to double,
  • string – sequence of Unicode characters,
  • boolean – binary data type of two possible values: true or false,
  • set – unordered collection of values.
  • array – ordered collection of values.

Except for set and array types, all of the types include special value of null, which, again, corresponds to the fact that null is an allowed and also default value for the item / user property values in the API.

ExpressionEquivalentComment
0123.000123.0

Leading and trailing zeros are ignored.

1.23e+31230.0

Exponential notation may be used.

1e91000000000

Using simple exponential notation for huge numbers.

123E-21.23

Negative exponents may also be used. Case of the e character does not matter.

ExpressionResultComment
1 + 23

Addition.

1 + 2 + 3 + 410

Chain of additions.

1 - 2-1

Subtraction.

1 - 2 - 3 - 4-9

Chain of subtractions.

-(1 + 2)-3

Unary minus.

2 * 36

Multiplication.

1 + 2 * 3 - 43

Standard operator precedence.

(1 + 2) * (3 - (4 + 5))-18

Bracketing.

10 / 52.0

Division.

1 / 20.5

Division always results in double, event if the operands are integers!

5 / 0NaN

If the divisor is 0, the result is NaN.

9 % 41

Modulo division.

3.14 % 2.50.64

Modulo division also works for doubles.

5 % 0NaN

If the divisor is 0, the result is NaN.

ExpressionResultComment
1 < 2.0true

Integers, doubles, and timestamps may be compared using standard comparison operators.

1 < 2 <= 2 == 2 != 1 >= 1 > 0true

Comparison operators may be arbitrarily chained.

1 < 2 <= 2 == 3 != 1 >= 1 > 0false

Chain of comparisons returns true if and only if all the individual comparisons are true.

2 == 2.0true

In comparison, there is no difference between integers, doubles, and timestamps.

ExpressionComment
"foo"

Strings constants are enclosed in double quotes.

""

Empty string.

"she said \"hello\""

Double quotes must be escaped.

"she said 'hello'"

Single quotes needn’t be escaped.

ExpressionResultComment
"foo" == "foo"true

Strings are compared for equality with ==.

"Alice" != nulltrue

Strings can be compared to null.

"Alice" < "Bob"true

Strings are ordered in lexicographic order.

"Alice" < "Bob" < "Carol" < "Dan"true

Comparisons may be chained arbitrarily.

"Alice" < "Bob" <= "Carol" != "Dan"true

Comparisons in the chain may be of different types.

"Alice" < "Bob" >= "Carol" != "Dan"false

All the comparisons must hold for the chain to return true.

"Alice" < 5error

Strings are only comparable with strings.

"Alice" ~ "A[a-z]+"true

Strings can be matched with regular expressions (regex).

ExpressionResultComment
"ice" in "Alice"true

in operator between strings tests whether the first string is contained in the second string.

"Ice" in "Alice"false

Containment test is case sensitive.

"ice" not in "Alice"false

in operator may be negated for better readability.

"" in "abc"true

Empty string is contained in every string.

"abc" in ""false

No non-empty string is contained in empty string.

5 in "abc"error

Both operands must be strings for string containment testing.

ExpressionResultComment
"foo" + "bar""foobar"

Strings can be concatenated using the + operator.

"" + "foo" + """foo"

Empty string is neutral element for concatenation.

"foo" + 123"foo123"

Strings can be concatenated with integers.

"foo" + 123.0"foo123.0"

Strings can be concatenated with numbers.

ExpressionResultComment
"abcd"[1]"b"

A character in the string can be accessed by its index (starting from 0).

"abcd"[10]""

Requesting an index outside the array boundaries results in an empty string.

"abcd"[-1]"d"

Negative indices are interpreted as counting from the end of the string. -1 therefore means the last character.

"abcd"[1:3]"bc"

It is possible to get a sub-string between two indices.

"abcd"[1:]"bcd"

If the second index is omitted, all characters until the end of the string are returned.

"abcd"[1::2]"bd"

Size of step can be provided to only take every n-th character.

"abcd"[::-3]"da"

Size of step can be negative. If first index is omitted, the slice begins with the last character.If the second index is omitted, the slice goes until the first character (inclusive).

ExpressionComment
{}

Empty set.

{1, 2, 3}

Set containing three integers.

{1, 2.0, false, "foo", null}

Sets may contain values of different types. This is an extension to sets in the API, which may only contain strings.

{{1,2}, {2,3}}

Sets may be nested.

ExpressionResultComment
{ 1, 1, 1, 2 }{ 1, 2 }

Sets only contain unique elements.

{ 1, 1.0 }{ 1.0 }

Integers, doubles, and timestamps, are merged.

{ {1,2}, {2,1} }{ {1,2} }

Merging also works for nested sets.

ExpressionResultComment
2 in { 1, 2, 3 }true

Using in operator, you may test whether a value is contained in given set (the ∈ relation)

4 not in { 1, 2, 3 }true

The in operator may be negated for better readability (the ∉ relation).

2.0 in { 1, 2, 3 }true

There is no difference between integers, doubles, and timestamps when testing containment.

"2" in { 1, 2, 3 }false

There is a difference between numbers and strings.

{ 1, 2 } in { 1, 2, 3 }false

in stands for ∈, not ⊆!

{ 1, 2 } in { {1,2}, {3,4} }true

in stands for ∈.

ExpressionResultComment
{ 1, 2 } < { 1, 2, 3 }true

Using < operator, you may test whether one test is a proper subset of another set (⊂ operator in set algebra).

{ 1, 2 } < { 1, 2 }false

No set is a proper subset of itself.

{} < { 1, 2 }true

Empty set is a proper subset of every non-empty set.

{} < {}false

Empty set is not a proper subset of itself.

{ 1, 2 } <= { 1, 2, 3 }true

Using <= operator, you may test whether one set is a subset of another set (⊆ operator is set algebra).

{ 1, 2 } <= { 1, 2 }true

Every set is a subset of itself.

{ 1, 2 } == { 1, 2 }true

== tests whether two sets are identical.

{ 1, 2 } != { 1, 2 }false

!= tests whether two sets are different.

{ 1, 2, 3 } >= { 1, 2 }true

>= operator tests whether one set is a superset of another set (⊇ operator in set algebra).

{ 1, 2 } >= { 1, 2 }true

Every set is a superset of itself.

{ 1, 2, 3 } > { 1, 2 }true

> operator tests whether one set is a proper superset of another set (⊃ operator in set algebra).

{ 1, 2 } > { 1, 2 }false

A non-empty set in not a proper superset of itself.

{ 1, 2 } > {}true

Every non-empty set is a proper superset of an empty set.

{} > {}false

Empty set is not a proper subset of itself.

ExpressionResultComment
{ 1, 2 } + { 2, 3 }{ 1, 2, 3 }

Sets may be unified using the + operator (∪ in set algebra).

{ 1, 2.0 } + { 2, 3 }{ 1, 2.0, 3 }

Integers, doubles, and timestamps are merged when unifying sets.

{ 1, 2 } + { 2, 3 } + { 4 }{ 1, 2, 3, 4 }

Unions may be chained.

{ 1, 2 } + {}{ 1, 2 }

Unification with empty set has no effect on the original set.

{ 1, 2 } + { "2", "3" }{ 1, 2, "2", "3" }

Strings and numbers are handled as different values.

ExpressionResultComment
{ 1, 2 } - { 2, 3 }{ 1 }

Set difference may be obtained using the - operator (operator is set algebra).

{ 1, 2 } - { 2.0, 3.0 }{ 1 }

Integers, doubles, and timestamps are considered equal if they equal in values.

{ 1, 2 } - {}{ 1, 2 }

Subtracting an empty set has no effect.

{ 1, 2 } - { 1 } - { 2 }{}

Chaining of set subtractions works from left to rights.

{ 1, 2 } - ({ 1, 2 } - { 2 }){ 2 }

Parenthesizing also works.

ExpressionResultComment
{ 1, 2 } & { 2, 3 }{ 2 }

Set intersection may be obtained using the & operator.

{ 1, 2 } & { 2.0, 3.0 }{ 2 }

Integers, doubles, and timestamps are considered equal if they equal in values.

{ 1, 2 } & {"1", "2"}{}

Strings and numbers are handled as different values.

{"a", { 1, 2 }} & {"b", { 1, 2 }}{{1,2}}

Works with subsets.

ExpressionResultComment
{ 1, 2 } / { 2, 3 }{ 1, 3 }

Symmetric difference of sets may be obtained using the / operator.

{ 1, 2 } / { 2.0, 3.0 }{ 1, 3 }

Integers, doubles, and timestamps are considered equal if they equal in values.

{ 1, 2 } / {"1", "2"}{1, 2, "1", "2"}

Strings and numbers are handled as different values.

{"a", { 1, 2 }} / {"b", { 1, 2 }}{"a", "b"}

Works with subsets.

ExpressionResultComment
[]

Empty array.

[1, 2, 3]

Array containing three integers.

[1, 2.0, false, "foo", null]

Arrays may contain values of different types.

[[1,2], [2,3]]

Arrays may be nested.

ExpressionResultComment
2 in [ 1, 2, 3 ]true

Using the in operator, you may test whether a value is contained in a given array.

4 not in [ 1, 2, 3 ]true

The in operator may be negated for better readability.

2.0 in [ 1, 2, 3 ]true

There is no difference between integers, doubles, and timestamps when testing containment.

"2" in [ 1, 2, 3 ]false

There is a difference between numbers and strings.

ExpressionResultComment
[ 1, 2 ] == [ 1, 2 ]true

== tests whether two arrays are identical.

[ 1, 2 ] != [ 1, 2 ]false

!= tests whether two arrays are different.

[ 1, 2 ] != [ 2, 1 ]true

Order of the elements must be the same in both arrays for equality

ExpressionResultComment
[ 1, 2 ] + [ 3, 4 ][ 1, 2, 3, 4 ]

Arrays may be concatenated using the + operator.

[ 1 ] + [ 2, 3 ] + [ 4 ][ 1, 2, 3, 4 ]

Concatenations may be chained.

[ 1, 2 ] + [][ 1, 2 ]

Concatenating an empty array has no effect on the original array.

ExpressionResultComment
[ "a", "b", "c", "d" ][1]"b"

Value can be accessed by their index (starting from 0).

[ "a", "b", "c", "d" ][10]null

Requesting an index outside the array boundaries results in null.

[ "a", "b", "c", "d" ][-1]"d"

Negative indices are interpreted as counting from the end of the array. -1 therefore means the last element.

[ "a", "b", "c", "d" ][1:3]["b", "c"]

It is possible to get a sub-array between two indices

[ "a", "b", "c", "d" ][1:]["b", "c", "d"]

If the second index is omitted, all elements until the end of the array are returned.

[ "a", "b", "c", "d" ][1::2]["b", "d"]

Size of step can be provided to only take every n-th element.

[ "a", "b", "c", "d" ][::-3]["d", "a"]

Size of step can be negative. If first index is omitted, the slice begins with the last element. If the second index is omitted, the slice goes until the first element (inclusive).

ExpressionComment
not 'a' == 'b''a' != 'b'
not 'a' > 'b''a' <= 'b'
not truefalse
not falsetrue

Implicit conversion to boolean (for advanced uses only!):

ExpressionResultComment
not -1false

Negative numbers are truthy.

not 0true

Zero numbers are falsy.

not 1.23false

Positive numbers are truthy.

not ""true

Empty strings are falsy.

not "foo"false

Non-empty strings are truthy.

not {}true

Empty sets are falsy.

not {1,2,3}false

Non-empty sets are truthy.

not nulltrue

null is falsy.

ExpressionabcResultComment
'a' > 'b' or 'a' > 'c'123false

If both operands are false, false is returned.

'a' > 'b' or 'a' > 'c'213true

If at least one of boolean operands is true, the result is true.

'a' > 'b' or 'a' > 'c'231true

If at least one of boolean operands is true, the result is true.

'a' > 'b' or 'a' > 'c'312true

If- both the operands are true, the result is true.

Advanced uses: Implicit conversion to boolean.

ExpressionResultComment
"foo" or "bar""foo"

If the first operand truthy, it is returned.

"" or falsefalse

If the first operand is falsy, the second operand is returned.

false or """"

If the first operand is falsy, the second operand is returned.

ExpressionabcResultComment
'a' > 'b' and 'a' > 'c'123false

If both operands are false, false is returned.

'a' > 'b' and 'a' > 'c'213false

If at least one of boolean operands is false, the result is false.

'a' > 'b' and 'a' > 'c'231false

If at least one of boolean operands is false, the result is false.

'a' > 'b' and 'a' > 'c'312true

If both the operands are true, the result is true.

Advanced uses: Implicit conversion to boolean.

ExpressionResultComment
"foo" and "bar""bar"

If the first operand truthy, the second operand is returned.

"" and false""

If the first operand is falsy, it is returned.

false and ""false

If the first operand is falsy, it is returned.

ExpressionabResultComment
if 'a' > 'b' then "foo" else "bar"105"foo"

then-value is returned if the condition is satisfied.

if 'a' < 'b' then "foo" else "bar"105"bar"

else-value is returned if the condition is not satisfied.

if 'a' < 'b' then "foo"error

else clause must always be present.

if 'a' < 'b' then "foo" else (if 'a' > 'b' then "bar" else "bah")55"bah"

if-else statements may be nested using parentheses.

ExpressionResultComment
if -1 then "foo" else "bar""foo"

Negative numbers are truthy.

if 0 then "foo" else "bar""bar"

Zero numbers are falsy.

if 1.23 then "foo" else "bar""foo"

Positive numbers are truthy.

if "" then "foo" else "bar""bar"

Empty strings are falsy.

if "bah" then "foo" else "bar""foo"

Non-empty strings are truthy.

if {} then "foo" else "bar""bar"

Empty sets are falsy

if {1,2,3} then "foo" else "bar""foo"

Non-empty sets are truthy.

if null then "foo" else "bar""bar"

null is falsy.

For more complex expressions, you might want to add comments to your ReQL code as documentation.

ReQL uses C-style comments, // for single-line comments, and /* */ for multi-line comments:

ReQL
// explain why you want to only show thrillers
"Thriller" in 'Genres'
ReQL
[
	"apple",
	"banana",
	/*   This is a multi-line comment
		 explaining why we include "cherry"
		 in this list. */
	"cherry"
]
© Copyright 2026, Recombee s.r.o
docs.recombee.com