Expression.Companion

public static class Expression.Companion


Summary

Public methods

static final @NonNull Expression
abs(@NonNull Expression numericExpr)

Creates an expression that returns the absolute value of numericExpr.

static final @NonNull Expression
abs(@NonNull String numericField)

Creates an expression that returns the absolute value of numericField.

static final @NonNull Expression

Creates an expression that adds numeric expressions.

static final @NonNull Expression
add(@NonNull Expression first, @NonNull Number second)

Creates an expression that adds numeric expressions with a constant.

static final @NonNull Expression
add(@NonNull String numericFieldName, @NonNull Expression second)

Creates an expression that adds a numeric field with a numeric expression.

static final @NonNull Expression
add(@NonNull String numericFieldName, @NonNull Number second)

Creates an expression that adds a numeric field with constant.

static final @NonNull BooleanExpression
and(
    @NonNull BooleanExpression condition,
    @NonNull BooleanExpression conditions
)

Creates an expression that performs a logical 'AND' operation.

static final @NonNull Expression
array(@NonNull List<Object> elements)

Creates an expression that creates a Firestore array value from an input array.

static final @NonNull Expression
array(Object elements)

Creates an expression that creates a Firestore array value from an input array.

static final @NonNull Expression
arrayConcat(
    @NonNull Expression firstArray,
    @NonNull Object secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates an array with other arrays.

static final @NonNull Expression
arrayConcat(
    @NonNull Expression firstArray,
    @NonNull Expression secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates an array with other arrays.

static final @NonNull Expression
arrayConcat(
    @NonNull String firstArrayField,
    @NonNull Object secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates a field's array value with other arrays.

static final @NonNull Expression
arrayConcat(
    @NonNull String firstArrayField,
    @NonNull Expression secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates a field's array value with other arrays.

static final @NonNull BooleanExpression

Creates an expression that checks if the array contains a specific element.

static final @NonNull BooleanExpression

Creates an expression that checks if the array contains a specific element.

static final @NonNull BooleanExpression
arrayContains(@NonNull String arrayFieldName, @NonNull Object element)

Creates an expression that checks if the array field contains a specific element.

static final @NonNull BooleanExpression
arrayContains(@NonNull String arrayFieldName, @NonNull Expression element)

Creates an expression that checks if the array field contains a specific element.

static final @NonNull BooleanExpression
arrayContainsAll(
    @NonNull Expression array,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array contains all elements of arrayExpression.

static final @NonNull BooleanExpression
arrayContainsAll(
    @NonNull Expression array,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array contains all the specified values.

static final @NonNull BooleanExpression
arrayContainsAll(
    @NonNull String arrayFieldName,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array field contains all elements of arrayExpression.

static final @NonNull BooleanExpression
arrayContainsAll(
    @NonNull String arrayFieldName,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array field contains all the specified values.

static final @NonNull BooleanExpression
arrayContainsAny(
    @NonNull Expression array,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array contains any elements of arrayExpression.

static final @NonNull BooleanExpression
arrayContainsAny(
    @NonNull Expression array,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array contains any of the specified values.

static final @NonNull BooleanExpression
arrayContainsAny(
    @NonNull String arrayFieldName,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array field contains any elements of arrayExpression.

static final @NonNull BooleanExpression
arrayContainsAny(
    @NonNull String arrayFieldName,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array field contains any of the specified values.

static final @NonNull Expression

Creates an expression that indexes into an array from the beginning or end and return the element.

static final @NonNull Expression
arrayGet(@NonNull Expression array, int offset)

Creates an expression that indexes into an array from the beginning or end and return the element.

static final @NonNull Expression
arrayGet(@NonNull String arrayFieldName, @NonNull Expression offset)

Creates an expression that indexes into an array from the beginning or end and return the element.

static final @NonNull Expression
arrayGet(@NonNull String arrayFieldName, int offset)

Creates an expression that indexes into an array from the beginning or end and return the element.

static final @NonNull Expression

Creates an expression that calculates the length of an array expression.

static final @NonNull Expression
arrayLength(@NonNull String arrayFieldName)

Creates an expression that calculates the length of an array field.

static final @NonNull Expression

Reverses the order of elements in the array.

static final @NonNull Expression
arrayReverse(@NonNull String arrayFieldName)

Reverses the order of elements in the array field.

static final @NonNull Expression

Creates an expression that returns the sum of the elements in an array.

static final @NonNull Expression
arraySum(@NonNull String arrayFieldName)

Creates an expression that returns the sum of the elements in an array field.

static final @NonNull Expression
bitAnd(@NonNull Expression bits, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise AND operation between an expression and a constant.

static final @NonNull Expression

Creates an expression that applies a bitwise AND operation between two expressions.

static final @NonNull Expression
bitAnd(@NonNull String bitsFieldName, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise AND operation between an field and constant.

static final @NonNull Expression
bitAnd(@NonNull String bitsFieldName, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise AND operation between an field and an expression.

static final @NonNull Expression
bitLeftShift(@NonNull Expression bits, int number)

Creates an expression that applies a bitwise left shift operation between an expression and a constant.

static final @NonNull Expression

Creates an expression that applies a bitwise left shift operation between two expressions.

static final @NonNull Expression
bitLeftShift(@NonNull String bitsFieldName, int number)

Creates an expression that applies a bitwise left shift operation between a field and a constant.

static final @NonNull Expression
bitLeftShift(@NonNull String bitsFieldName, @NonNull Expression numberExpr)

Creates an expression that applies a bitwise left shift operation between a field and an expression.

static final @NonNull Expression

Creates an expression that applies a bitwise NOT operation to an expression.

static final @NonNull Expression
bitNot(@NonNull String bitsFieldName)

Creates an expression that applies a bitwise NOT operation to a field.

static final @NonNull Expression
bitOr(@NonNull Expression bits, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise OR operation between an expression and a constant.

static final @NonNull Expression
bitOr(@NonNull Expression bits, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise OR operation between two expressions.

static final @NonNull Expression
bitOr(@NonNull String bitsFieldName, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise OR operation between an field and constant.

static final @NonNull Expression
bitOr(@NonNull String bitsFieldName, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise OR operation between an field and an expression.

static final @NonNull Expression
bitRightShift(@NonNull Expression bits, int number)

Creates an expression that applies a bitwise right shift operation between an expression and a constant.

static final @NonNull Expression

Creates an expression that applies a bitwise right shift operation between two expressions.

static final @NonNull Expression
bitRightShift(@NonNull String bitsFieldName, int number)

Creates an expression that applies a bitwise right shift operation between a field and a constant.

static final @NonNull Expression
bitRightShift(
    @NonNull String bitsFieldName,
    @NonNull Expression numberExpr
)

Creates an expression that applies a bitwise right shift operation between a field and an expression.

static final @NonNull Expression
bitXor(@NonNull Expression bits, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise XOR operation between an expression and a constant.

static final @NonNull Expression

Creates an expression that applies a bitwise XOR operation between two expressions.

static final @NonNull Expression
bitXor(@NonNull String bitsFieldName, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise XOR operation between an field and constant.

static final @NonNull Expression
bitXor(@NonNull String bitsFieldName, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise XOR operation between an field and an expression.

static final @NonNull Expression

Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob.

static final @NonNull Expression

Creates an expression that calculates the length of a string in UTF-8 bytes, or just the length of a Blob.

static final @NonNull Expression
ceil(@NonNull Expression numericExpr)

Creates an expression that returns the smallest integer that isn't less than numericExpr.

static final @NonNull Expression
ceil(@NonNull String numericField)

Creates an expression that returns the smallest integer that isn't less than numericField.

static final @NonNull Expression

Creates an expression that calculates the character length of a string expression in UTF8.

static final @NonNull Expression

Creates an expression that calculates the character length of a string field in UTF8.

static final @NonNull Expression

Creates an expression that returns the collection ID from a path.

static final @NonNull Expression

Creates an expression that returns the collection ID from a path.

static final @NonNull Expression
concat(
    @NonNull Expression first,
    @NonNull Object second,
    @NonNull Object others
)

Creates an expression that concatenates strings, arrays, or blobs.

static final @NonNull Expression
concat(
    @NonNull Expression first,
    @NonNull Expression second,
    @NonNull Object others
)

Creates an expression that concatenates strings, arrays, or blobs.

static final @NonNull Expression
concat(@NonNull String first, @NonNull Object second, @NonNull Object others)

Creates an expression that concatenates strings, arrays, or blobs.

static final @NonNull Expression
concat(
    @NonNull String first,
    @NonNull Expression second,
    @NonNull Object others
)

Creates an expression that concatenates strings, arrays, or blobs.

static final @NonNull Expression
conditional(
    @NonNull BooleanExpression condition,
    @NonNull Expression thenExpr,
    @NonNull Expression elseExpr
)

Creates a conditional expression that evaluates to a thenExpr expression if a condition is true or an elseExpr expression if the condition is false.

static final @NonNull Expression
conditional(
    @NonNull BooleanExpression condition,
    @NonNull Object thenValue,
    @NonNull Object elseValue
)

Creates a conditional expression that evaluates to a thenValue if a condition is true or an elseValue if the condition is false.

static final @NonNull Expression

Create a constant for a DocumentReference value.

static final @NonNull Expression

Create a constant for a Blob value.

static final @NonNull BooleanExpression
constant(boolean value)

Create a constant for a Boolean value.

static final @NonNull Expression
constant(@NonNull byte[] value)

Create a constant for a bytes value.

static final @NonNull Expression

Create a constant for a Date value.

static final @NonNull Expression

Create a constant for a GeoPoint value.

static final @NonNull Expression

Create a constant for a Number value.

static final @NonNull Expression

Create a constant for a String value.

static final @NonNull Expression

Create a constant for a Timestamp value.

static final @NonNull Expression

Create a constant for a VectorValue value.

static final @NonNull Expression
cosineDistance(@NonNull Expression vector1, @NonNull double[] vector2)

Calculates the Cosine distance between vector expression and a vector literal.

static final @NonNull Expression

Calculates the Cosine distance between two vector expressions.

static final @NonNull Expression

Calculates the Cosine distance between vector expression and a vector literal.

static final @NonNull Expression
cosineDistance(@NonNull String vectorFieldName, @NonNull double[] vector)

Calculates the Cosine distance between a vector field and a vector literal.

static final @NonNull Expression
cosineDistance(@NonNull String vectorFieldName, @NonNull Expression vector)

Calculates the Cosine distance between a vector field and a vector expression.

static final @NonNull Expression
cosineDistance(
    @NonNull String vectorFieldName,
    @NonNull VectorValue vector
)

Calculates the Cosine distance between a vector field and a vector literal.

static final @NonNull Expression

Creates an expression that evaluates to the current server timestamp.

static final @NonNull Expression
divide(@NonNull Expression dividend, @NonNull Expression divisor)

Creates an expression that divides two numeric expressions.

static final @NonNull Expression
divide(@NonNull Expression dividend, @NonNull Number divisor)

Creates an expression that divides a numeric expression by a constant.

static final @NonNull Expression
divide(@NonNull String dividendFieldName, @NonNull Expression divisor)

Creates an expression that divides numeric field by a numeric expression.

static final @NonNull Expression
divide(@NonNull String dividendFieldName, @NonNull Number divisor)

Creates an expression that divides a numeric field by a constant.

static final @NonNull Expression

Creates an expression that returns the document ID from a DocumentReference.

static final @NonNull Expression
documentId(@NonNull Expression documentPath)

Creates an expression that returns the document ID from a path.

static final @NonNull Expression
documentId(@NonNull String documentPath)

Creates an expression that returns the document ID from a path.

static final @NonNull Expression
dotProduct(@NonNull Expression vector1, @NonNull double[] vector2)

Calculates the dot product distance between vector expression and a vector literal.

static final @NonNull Expression

Calculates the dot product distance between two vector expressions.

static final @NonNull Expression

Calculates the dot product distance between vector expression and a vector literal.

static final @NonNull Expression
dotProduct(@NonNull String vectorFieldName, @NonNull double[] vector)

Calculates the dot product distance between vector field and a vector literal.

static final @NonNull Expression
dotProduct(@NonNull String vectorFieldName, @NonNull Expression vector)

Calculates the dot product distance between a vector field and a vector expression.

static final @NonNull Expression
dotProduct(@NonNull String vectorFieldName, @NonNull VectorValue vector)

Calculates the dot product distance between a vector field and a vector literal.

static final @NonNull BooleanExpression
endsWith(@NonNull String fieldName, @NonNull Expression suffix)

Creates an expression that checks if a string expression ends with a given suffix.

static final @NonNull BooleanExpression
endsWith(@NonNull String fieldName, @NonNull String suffix)

Creates an expression that checks if a string expression ends with a given suffix.

static final @NonNull BooleanExpression
endsWith(@NonNull Expression stringExpr, @NonNull Expression suffix)

Creates an expression that checks if a string expression ends with a given suffix.

static final @NonNull BooleanExpression
endsWith(@NonNull Expression stringExpr, @NonNull String suffix)

Creates an expression that checks if a string expression ends with a given suffix.

static final @NonNull BooleanExpression
equal(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is equal to an expression.

static final @NonNull BooleanExpression
equal(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is equal to another value.

static final @NonNull BooleanExpression

Creates an expression that checks if an expression is equal to a value.

static final @NonNull BooleanExpression

Creates an expression that checks if two expressions are equal.

static final @NonNull BooleanExpression
equalAny(
    @NonNull Expression expression,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if an expression, when evaluated, is equal to any of the elements of arrayExpression.

static final @NonNull BooleanExpression
equalAny(
    @NonNull Expression expression,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if an expression, when evaluated, is equal to any of the provided values.

static final @NonNull BooleanExpression
equalAny(@NonNull String fieldName, @NonNull Expression arrayExpression)

Creates an expression that checks if a field's value is equal to any of the elements of arrayExpression.

static final @NonNull BooleanExpression
equalAny(@NonNull String fieldName, @NonNull List<@NonNull Object> values)

Creates an expression that checks if a field's value is equal to any of the provided values .

static final @NonNull Expression
euclideanDistance(@NonNull Expression vector1, @NonNull double[] vector2)

Calculates the Euclidean distance between vector expression and a vector literal.

static final @NonNull Expression

Calculates the Euclidean distance between two vector expressions.

static final @NonNull Expression
euclideanDistance(
    @NonNull Expression vector1,
    @NonNull VectorValue vector2
)

Calculates the Euclidean distance between vector expression and a vector literal.

static final @NonNull Expression
euclideanDistance(
    @NonNull String vectorFieldName,
    @NonNull double[] vector
)

Calculates the Euclidean distance between a vector field and a vector literal.

static final @NonNull Expression
euclideanDistance(
    @NonNull String vectorFieldName,
    @NonNull Expression vector
)

Calculates the Euclidean distance between a vector field and a vector expression.

static final @NonNull Expression
euclideanDistance(
    @NonNull String vectorFieldName,
    @NonNull VectorValue vector
)

Calculates the Euclidean distance between a vector field and a vector literal.

static final @NonNull BooleanExpression
exists(@NonNull String fieldName)

Creates an expression that checks if a field exists.

static final @NonNull BooleanExpression

Creates an expression that checks if a field exists.

static final @NonNull Expression
exp(@NonNull Expression numericExpr)

Creates an expression that returns Euler's number e raised to the power of numericExpr.

static final @NonNull Expression
exp(@NonNull String numericField)

Creates an expression that returns Euler's number e raised to the power of numericField.

static final @NonNull Field
field(@NonNull FieldPath fieldPath)

Creates a Field instance representing the field at the given path.

static final @NonNull Field

Creates a Field instance representing the field at the given path.

static final @NonNull Expression
floor(@NonNull Expression numericExpr)

Creates an expression that returns the largest integer that is not greater than numericExpr

static final @NonNull Expression
floor(@NonNull String numericField)

Creates an expression that returns the largest integer that is not greater than numericField.

static final @NonNull BooleanExpression
greaterThan(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is greater than an expression.

static final @NonNull BooleanExpression
greaterThan(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is greater than another value.

static final @NonNull BooleanExpression

Creates an expression that checks if an expression is greater than a value.

static final @NonNull BooleanExpression

Creates an expression that checks if the first expression is greater than the second expression.

static final @NonNull BooleanExpression
greaterThanOrEqual(
    @NonNull String fieldName,
    @NonNull Expression expression
)

Creates an expression that checks if a field's value is greater than or equal to an expression.

static final @NonNull BooleanExpression

Creates an expression that checks if a field's value is greater than or equal to another value.

static final @NonNull BooleanExpression

Creates an expression that checks if an expression is greater than or equal to a value.

static final @NonNull BooleanExpression

Creates an expression that checks if the first expression is greater than or equal to the second expression.

static final @NonNull Expression

Creates an expression that returns the elseExpr argument if ifExpr is absent, else return the result of the ifExpr argument evaluation.

static final @NonNull Expression
ifAbsent(@NonNull Expression ifExpr, @NonNull Object elseValue)

Creates an expression that returns the elseValue argument if ifExpr is absent, else return the result of the ifExpr argument evaluation.

static final @NonNull Expression
ifAbsent(@NonNull String ifFieldName, @NonNull Expression elseExpr)

Creates an expression that returns the elseExpr argument if ifFieldName is absent, else return the value of the field.

static final @NonNull Expression
ifAbsent(@NonNull String ifFieldName, @NonNull Object elseValue)

Creates an expression that returns the elseValue argument if ifFieldName is absent, else return the value of the field.

static final @NonNull BooleanExpression
ifError(
    @NonNull BooleanExpression tryExpr,
    @NonNull BooleanExpression catchExpr
)

Creates an expression that returns the catchExpr argument if there is an error, else return the result of the tryExpr argument evaluation.

static final @NonNull Expression
ifError(@NonNull Expression tryExpr, @NonNull Expression catchExpr)

Creates an expression that returns the catchExpr argument if there is an error, else return the result of the tryExpr argument evaluation.

static final @NonNull Expression
ifError(@NonNull Expression tryExpr, @NonNull Object catchValue)

Creates an expression that returns the catchValue argument if there is an error, else return the result of the tryExpr argument evaluation.

static final @NonNull BooleanExpression
isAbsent(@NonNull String fieldName)

Creates an expression that returns true if a field is absent.

static final @NonNull BooleanExpression

Creates an expression that returns true if a value is absent.

static final @NonNull BooleanExpression

Creates an expression that checks if a given expression produces an error.

static final @NonNull Expression
join(@NonNull Expression arrayExpression, @NonNull String delimiter)

Creates an expression that joins the elements of an array into a string.

static final @NonNull Expression
join(
    @NonNull Expression arrayExpression,
    @NonNull Expression delimiterExpression
)

Creates an expression that joins the elements of an array into a string.

static final @NonNull Expression
join(@NonNull String arrayFieldName, @NonNull String delimiter)

Creates an expression that joins the elements of an array field into a string.

static final @NonNull Expression
join(
    @NonNull String arrayFieldName,
    @NonNull Expression delimiterExpression
)

Creates an expression that joins the elements of an array field into a string.

static final @NonNull Expression

Creates an expression that calculates the length of a string, array, map, vector, or blob expression.

static final @NonNull Expression
length(@NonNull String fieldName)

Creates an expression that calculates the length of a string, array, map, vector, or blob field.

static final @NonNull BooleanExpression
lessThan(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is less than an expression.

static final @NonNull BooleanExpression
lessThan(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is less than another value.

static final @NonNull BooleanExpression

Creates an expression that checks if an expression is less than a value.

static final @NonNull BooleanExpression

Creates an expression that checks if the first expression is less than the second expression.

static final @NonNull BooleanExpression
lessThanOrEqual(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is less than or equal to an expression.

static final @NonNull BooleanExpression

Creates an expression that checks if a field's value is less than or equal to another value.

static final @NonNull BooleanExpression

Creates an expression that checks if an expression is less than or equal to a value.

static final @NonNull BooleanExpression

Creates an expression that checks if the first expression is less than or equal to the second expression.

static final @NonNull BooleanExpression
like(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that performs a case-sensitive wildcard string comparison against a field.

static final @NonNull BooleanExpression
like(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that performs a case-sensitive wildcard string comparison against a field.

static final @NonNull BooleanExpression
like(@NonNull Expression stringExpression, @NonNull Expression pattern)

Creates an expression that performs a case-sensitive wildcard string comparison.

static final @NonNull BooleanExpression
like(@NonNull Expression stringExpression, @NonNull String pattern)

Creates an expression that performs a case-sensitive wildcard string comparison.

static final @NonNull Expression
ln(@NonNull Expression numericExpr)

Creates an expression that returns the natural logarithm (base e) of numericExpr.

static final @NonNull Expression
ln(@NonNull String numericField)

Creates an expression that returns the natural logarithm (base e) of numericField.

static final @NonNull Expression
log(@NonNull Expression numericExpr, @NonNull Expression base)

Creates an expression that returns the logarithm of numericExpr with a given base.

static final @NonNull Expression
log(@NonNull Expression numericExpr, @NonNull Number base)

Creates an expression that returns the logarithm of numericExpr with a given base.

static final @NonNull Expression
log(@NonNull String numericField, @NonNull Expression base)

Creates an expression that returns the logarithm of numericField with a given base.

static final @NonNull Expression
log(@NonNull String numericField, @NonNull Number base)

Creates an expression that returns the logarithm of numericField with a given base.

static final @NonNull Expression
log10(@NonNull Expression numericExpr)

Creates an expression that returns the base 10 logarithm of numericExpr.

static final @NonNull Expression
log10(@NonNull String numericField)

Creates an expression that returns the base 10 logarithm of numericField.

static final @NonNull Expression

Creates an expression that returns the largest value between multiple input expressions or literal values.

static final @NonNull Expression
logicalMaximum(@NonNull String fieldName, @NonNull Object others)

Creates an expression that returns the largest value between multiple input expressions or literal values.

static final @NonNull Expression

Creates an expression that returns the smallest value between multiple input expressions or literal values.

static final @NonNull Expression
logicalMinimum(@NonNull String fieldName, @NonNull Object others)

Creates an expression that returns the smallest value between multiple input expressions or literal values.

static final @NonNull Expression

Creates an expression that creates a Firestore map value from an input object.

static final @NonNull Expression
mapGet(@NonNull String fieldName, @NonNull String key)

Accesses a value from a map (object) field using the provided key.

static final @NonNull Expression
mapGet(@NonNull String fieldName, @NonNull Expression keyExpression)

Accesses a value from a map (object) field using the provided keyExpression.

static final @NonNull Expression
mapGet(@NonNull Expression mapExpression, @NonNull String key)

Accesses a value from a map (object) field using the provided key.

static final @NonNull Expression
mapGet(
    @NonNull Expression mapExpression,
    @NonNull Expression keyExpression
)

Accesses a value from a map (object) field using the provided keyExpression.

static final @NonNull Expression
mapMerge(
    @NonNull Expression firstMap,
    @NonNull Expression secondMap,
    @NonNull Expression otherMaps
)

Creates an expression that merges multiple maps into a single map.

static final @NonNull Expression
mapMerge(
    @NonNull String firstMapFieldName,
    @NonNull Expression secondMap,
    @NonNull Expression otherMaps
)

Creates an expression that merges multiple maps into a single map.

static final @NonNull Expression

Creates an expression that removes a key from the map produced by evaluating an expression.

static final @NonNull Expression

Creates an expression that removes a key from the map produced by evaluating an expression.

static final @NonNull Expression

Creates an expression that removes a key from the map produced by evaluating an expression.

static final @NonNull Expression
mapRemove(@NonNull String mapField, @NonNull String key)

Creates an expression that removes a key from the map produced by evaluating an expression.

static final @NonNull Expression
mod(@NonNull Expression dividend, @NonNull Expression divisor)

Creates an expression that calculates the modulo (remainder) of dividing two numeric expressions.

static final @NonNull Expression
mod(@NonNull Expression dividend, @NonNull Number divisor)

Creates an expression that calculates the modulo (remainder) of dividing a numeric expression by a constant.

static final @NonNull Expression
mod(@NonNull String dividendFieldName, @NonNull Expression divisor)

Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a constant.

static final @NonNull Expression
mod(@NonNull String dividendFieldName, @NonNull Number divisor)

Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a constant.

static final @NonNull Expression

Creates an expression that multiplies numeric expressions.

static final @NonNull Expression

Creates an expression that multiplies numeric expressions with a constant.

static final @NonNull Expression
multiply(@NonNull String numericFieldName, @NonNull Expression second)

Creates an expression that multiplies a numeric field with a numeric expression.

static final @NonNull Expression
multiply(@NonNull String numericFieldName, @NonNull Number second)

Creates an expression that multiplies a numeric field with a constant.

static final @NonNull BooleanExpression

Creates an expression that negates a boolean expression.

static final @NonNull BooleanExpression
notEqual(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is not equal to an expression.

static final @NonNull BooleanExpression
notEqual(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is not equal to another value.

static final @NonNull BooleanExpression

Creates an expression that checks if an expression is not equal to a value.

static final @NonNull BooleanExpression

Creates an expression that checks if two expressions are not equal.

static final @NonNull BooleanExpression
notEqualAny(
    @NonNull Expression expression,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if an expression, when evaluated, is not equal to all the elements of arrayExpression.

static final @NonNull BooleanExpression
notEqualAny(
    @NonNull Expression expression,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if an expression, when evaluated, is not equal to all the provided values.

static final @NonNull BooleanExpression
notEqualAny(@NonNull String fieldName, @NonNull Expression arrayExpression)

Creates an expression that checks if a field's value is not equal to all of the elements of arrayExpression.

static final @NonNull BooleanExpression
notEqualAny(@NonNull String fieldName, @NonNull List<@NonNull Object> values)

Creates an expression that checks if a field's value is not equal to all of the provided values.

static final @NonNull Expression

Constant for a null value.

static final @NonNull BooleanExpression
or(
    @NonNull BooleanExpression condition,
    @NonNull BooleanExpression conditions
)

Creates an expression that performs a logical 'OR' operation.

static final @NonNull Expression
pow(@NonNull Expression numericExpr, @NonNull Expression exponent)

Creates an expression that returns the numericExpr raised to the power of the exponent.

static final @NonNull Expression
pow(@NonNull Expression numericExpr, @NonNull Number exponent)

Creates an expression that returns the numericExpr raised to the power of the exponent.

static final @NonNull Expression
pow(@NonNull String numericField, @NonNull Expression exponent)

Creates an expression that returns the numericField raised to the power of the exponent.

static final @NonNull Expression
pow(@NonNull String numericField, @NonNull Number exponent)

Creates an expression that returns the numericField raised to the power of the exponent.

static final @NonNull Expression

Creates a 'raw' function expression.

static final @NonNull BooleanExpression
regexContains(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that checks if a string field contains a specified regular expression as a substring.

static final @NonNull BooleanExpression
regexContains(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that checks if a string field contains a specified regular expression as a substring.

static final @NonNull BooleanExpression
regexContains(
    @NonNull Expression stringExpression,
    @NonNull Expression pattern
)

Creates an expression that checks if a string expression contains a specified regular expression as a substring.

static final @NonNull BooleanExpression
regexContains(
    @NonNull Expression stringExpression,
    @NonNull String pattern
)

Creates an expression that checks if a string expression contains a specified regular expression as a substring.

static final @NonNull BooleanExpression
regexMatch(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that checks if a string field matches a specified regular expression.

static final @NonNull BooleanExpression
regexMatch(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that checks if a string field matches a specified regular expression.

static final @NonNull BooleanExpression
regexMatch(
    @NonNull Expression stringExpression,
    @NonNull Expression pattern
)

Creates an expression that checks if a string field matches a specified regular expression.

static final @NonNull BooleanExpression
regexMatch(@NonNull Expression stringExpression, @NonNull String pattern)

Creates an expression that checks if a string field matches a specified regular expression.

static final @NonNull Expression
reverse(@NonNull String fieldName)

Creates an expression that reverses a string value from the specified field.

static final @NonNull Expression
reverse(@NonNull Expression stringExpression)

Creates an expression that reverses a string.

static final @NonNull Expression
round(@NonNull Expression numericExpr)

Creates an expression that rounds numericExpr to nearest integer.

static final @NonNull Expression
round(@NonNull String numericField)

Creates an expression that rounds numericField to nearest integer.

static final @NonNull Expression
roundToPrecision(
    @NonNull Expression numericExpr,
    @NonNull Expression decimalPlace
)

Creates an expression that rounds off numericExpr to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative.

static final @NonNull Expression
roundToPrecision(@NonNull Expression numericExpr, int decimalPlace)

Creates an expression that rounds off numericExpr to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative.

static final @NonNull Expression
roundToPrecision(
    @NonNull String numericField,
    @NonNull Expression decimalPlace
)

Creates an expression that rounds off numericField to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative.

static final @NonNull Expression
roundToPrecision(@NonNull String numericField, int decimalPlace)

Creates an expression that rounds off numericField to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative.

static final @NonNull Expression
split(@NonNull String fieldName, @NonNull Blob delimiter)

Creates an expression that splits a blob field by a blob delimiter.

static final @NonNull Expression
split(@NonNull String fieldName, @NonNull Expression delimiter)

Creates an expression that splits a string or blob field by a delimiter.

static final @NonNull Expression
split(@NonNull String fieldName, @NonNull String delimiter)

Creates an expression that splits a string or blob field by a string delimiter.

static final @NonNull Expression
split(@NonNull Expression value, @NonNull Blob delimiter)

Creates an expression that splits a blob by a blob delimiter.

static final @NonNull Expression
split(@NonNull Expression value, @NonNull Expression delimiter)

Creates an expression that splits a string or blob by a delimiter.

static final @NonNull Expression
split(@NonNull Expression value, @NonNull String delimiter)

Creates an expression that splits a string or blob by a string delimiter.

static final @NonNull Expression
sqrt(@NonNull Expression numericExpr)

Creates an expression that returns the square root of numericExpr.

static final @NonNull Expression
sqrt(@NonNull String numericField)

Creates an expression that returns the square root of numericField.

static final @NonNull BooleanExpression
startsWith(@NonNull String fieldName, @NonNull Expression prefix)

Creates an expression that checks if a string expression starts with a given prefix.

static final @NonNull BooleanExpression
startsWith(@NonNull String fieldName, @NonNull String prefix)

Creates an expression that checks if a string expression starts with a given prefix.

static final @NonNull BooleanExpression
// Check if the 'fullName' field starts with the value of the 'firstName' field
startsWith(field("fullName"), field("firstName"))
static final @NonNull BooleanExpression
startsWith(@NonNull Expression stringExpr, @NonNull String prefix)

Creates an expression that checks if a string expression starts with a given prefix.

static final @NonNull Expression
stringConcat(@NonNull String fieldName, @NonNull Object otherStrings)

Creates an expression that concatenates string expressions together.

static final @NonNull Expression
stringConcat(@NonNull String fieldName, @NonNull Expression otherStrings)

Creates an expression that concatenates string expressions together.

static final @NonNull Expression
stringConcat(@NonNull Expression firstString, @NonNull Object otherStrings)

Creates an expression that concatenates string expressions together.

static final @NonNull Expression
stringConcat(
    @NonNull Expression firstString,
    @NonNull Expression otherStrings
)

Creates an expression that concatenates string expressions together.

static final @NonNull BooleanExpression
stringContains(@NonNull String fieldName, @NonNull Expression substring)

Creates an expression that checks if a string field contains a specified substring.

static final @NonNull BooleanExpression
stringContains(@NonNull String fieldName, @NonNull String substring)

Creates an expression that checks if a string field contains a specified substring.

static final @NonNull BooleanExpression
stringContains(
    @NonNull Expression stringExpression,
    @NonNull Expression substring
)

Creates an expression that checks if a string expression contains a specified substring.

static final @NonNull BooleanExpression
stringContains(
    @NonNull Expression stringExpression,
    @NonNull String substring
)

Creates an expression that checks if a string expression contains a specified substring.

static final @NonNull Expression

Reverses the given string field.

static final @NonNull Expression

Reverses the given string expression.

static final @NonNull Expression
substring(@NonNull String fieldName, int index, int length)

Creates an expression that returns a substring of the given string.

static final @NonNull Expression
substring(
    @NonNull Expression stringExpression,
    @NonNull Expression index,
    @NonNull Expression length
)

Creates an expression that returns a substring of the given string.

static final @NonNull Expression
subtract(@NonNull Expression minuend, @NonNull Expression subtrahend)

Creates an expression that subtracts two expressions.

static final @NonNull Expression
subtract(@NonNull Expression minuend, @NonNull Number subtrahend)

Creates an expression that subtracts a constant value from a numeric expression.

static final @NonNull Expression
subtract(@NonNull String numericFieldName, @NonNull Expression subtrahend)

Creates an expression that subtracts a numeric expressions from numeric field.

static final @NonNull Expression
subtract(@NonNull String numericFieldName, @NonNull Number subtrahend)

Creates an expression that subtracts a constant from numeric field.

static final @NonNull Expression
timestampAdd(
    @NonNull String fieldName,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that adds a specified amount of time to a timestamp.

static final @NonNull Expression
timestampAdd(@NonNull String fieldName, @NonNull String unit, long amount)

Creates an expression that adds a specified amount of time to a timestamp.

static final @NonNull Expression
timestampAdd(
    @NonNull Expression timestamp,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that adds a specified amount of time to a timestamp.

static final @NonNull Expression
timestampAdd(
    @NonNull Expression timestamp,
    @NonNull String unit,
    long amount
)

Creates an expression that adds a specified amount of time to a timestamp.

static final @NonNull Expression
timestampSubtract(
    @NonNull String fieldName,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

static final @NonNull Expression
timestampSubtract(
    @NonNull String fieldName,
    @NonNull String unit,
    long amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

static final @NonNull Expression
timestampSubtract(
    @NonNull Expression timestamp,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

static final @NonNull Expression
timestampSubtract(
    @NonNull Expression timestamp,
    @NonNull String unit,
    long amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

static final @NonNull Expression

Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

static final @NonNull Expression

Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

static final @NonNull Expression

Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

static final @NonNull Expression

Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

static final @NonNull Expression

Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).

static final @NonNull Expression

Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).

static final @NonNull Expression
timestampTruncate(
    @NonNull String fieldName,
    @NonNull Expression granularity
)

Creates an expression that truncates a timestamp to a specified granularity.

static final @NonNull Expression
timestampTruncate(@NonNull String fieldName, @NonNull String granularity)

Creates an expression that truncates a timestamp to a specified granularity.

static final @NonNull Expression
timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull Expression granularity
)

Creates an expression that truncates a timestamp to a specified granularity.

static final @NonNull Expression
timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull String granularity
)

Creates an expression that truncates a timestamp to a specified granularity.

static final @NonNull Expression
timestampTruncate(
    @NonNull String fieldName,
    @NonNull Expression granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

static final @NonNull Expression
timestampTruncate(
    @NonNull String fieldName,
    @NonNull String granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

static final @NonNull Expression
timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull Expression granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

static final @NonNull Expression
timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull String granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

static final @NonNull Expression
toLower(@NonNull String fieldName)

Creates an expression that converts a string field to lowercase.

static final @NonNull Expression
toLower(@NonNull Expression stringExpression)

Creates an expression that converts a string expression to lowercase.

static final @NonNull Expression
toUpper(@NonNull String fieldName)

Creates an expression that converts a string field to uppercase.

static final @NonNull Expression
toUpper(@NonNull Expression stringExpression)

Creates an expression that converts a string expression to uppercase.

static final @NonNull Expression
trim(@NonNull String fieldName)

Creates an expression that removes leading and trailing whitespace from a string field.

static final @NonNull Expression
trim(@NonNull Expression stringExpression)

Creates an expression that removes leading and trailing whitespace from a string expression.

static final @NonNull Expression
trimValue(@NonNull String fieldName, @NonNull String valueToTrim)

Creates an expression that removes leading and trailing characters from a string field.

static final @NonNull Expression
trimValue(
    @NonNull Expression stringExpression,
    @NonNull Expression valueToTrim
)

Creates an expression that removes leading and trailing values from a expression.

static final @NonNull Expression

Creates an expression that returns a string indicating the type of the value this expression evaluates to.

static final @NonNull Expression
type(@NonNull String fieldName)

Creates an expression that returns a string indicating the type of the value this field evaluates to.

static final @NonNull Expression

Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

static final @NonNull Expression

Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

static final @NonNull Expression

Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

static final @NonNull Expression

Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

static final @NonNull Expression

Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

static final @NonNull Expression

Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

static final @NonNull Expression
vector(@NonNull double[] vector)

Create a vector constant for a DoubleArray value.

static final @NonNull Expression

Create a vector constant for a VectorValue value.

static final @NonNull Expression

Creates an expression that calculates the length (dimension) of a Firestore Vector.

static final @NonNull Expression
vectorLength(@NonNull Expression vectorExpression)

Creates an expression that calculates the length (dimension) of a Firestore Vector.

static final @NonNull BooleanExpression
xor(
    @NonNull BooleanExpression condition,
    @NonNull BooleanExpression conditions
)

Creates an expression that performs a logical 'XOR' operation.

Public methods

abs

public static final @NonNull Expression abs(@NonNull Expression numericExpr)

Creates an expression that returns the absolute value of numericExpr.

// Get the absolute value of the 'change' field.
abs(field("change"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the absolute value operation.

abs

public static final @NonNull Expression abs(@NonNull String numericField)

Creates an expression that returns the absolute value of numericField.

// Get the absolute value of the 'change' field.
abs("change")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the absolute value operation.

add

public static final @NonNull Expression add(@NonNull Expression first, @NonNull Expression second)

Creates an expression that adds numeric expressions.

// Add the value of the 'quantity' field and the 'reserve' field.
add(field("quantity"), field("reserve"))
Parameters
@NonNull Expression first

Numeric expression to add.

@NonNull Expression second

Numeric expression to add.

Returns
@NonNull Expression

A new Expression representing the addition operation.

add

public static final @NonNull Expression add(@NonNull Expression first, @NonNull Number second)

Creates an expression that adds numeric expressions with a constant.

// Add 5 to the value of the 'quantity' field.
add(field("quantity"), 5)
Parameters
@NonNull Expression first

Numeric expression to add.

@NonNull Number second

Constant to add.

Returns
@NonNull Expression

A new Expression representing the addition operation.

add

public static final @NonNull Expression add(@NonNull String numericFieldName, @NonNull Expression second)

Creates an expression that adds a numeric field with a numeric expression.

// Add the value of the 'quantity' field and the 'reserve' field.
add("quantity", field("reserve"))
Parameters
@NonNull String numericFieldName

Numeric field to add.

@NonNull Expression second

Numeric expression to add to field value.

Returns
@NonNull Expression

A new Expression representing the addition operation.

add

public static final @NonNull Expression add(@NonNull String numericFieldName, @NonNull Number second)

Creates an expression that adds a numeric field with constant.

// Add 5 to the value of the 'quantity' field.
add("quantity", 5)
Parameters
@NonNull String numericFieldName

Numeric field to add.

@NonNull Number second

Constant to add.

Returns
@NonNull Expression

A new Expression representing the addition operation.

and

public static final @NonNull BooleanExpression and(
    @NonNull BooleanExpression condition,
    @NonNull BooleanExpression conditions
)

Creates an expression that performs a logical 'AND' operation.

// Check if 'status' is "new" and 'priority' is greater than 1
and(field("status").equal("new"), field("priority").greaterThan(1))
Parameters
@NonNull BooleanExpression condition

The first BooleanExpression.

@NonNull BooleanExpression conditions

Additional BooleanExpressions.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the logical 'AND' operation.

array

public static final @NonNull Expression array(@NonNull List<Object> elements)

Creates an expression that creates a Firestore array value from an input array.

Parameters
@NonNull List<Object> elements

The input array to evaluate in the expression.

Returns
@NonNull Expression

A new Expression representing the array function.

array

public static final @NonNull Expression array(Object elements)

Creates an expression that creates a Firestore array value from an input array.

// Create an array of numbers
array
(1, 2, 3)

// Create an array containing a field value and a constant
array
(field("quantity"), 10)
Parameters
Object elements

The input array to evaluate in the expression.

Returns
@NonNull Expression

A new Expression representing the array function.

arrayConcat

public static final @NonNull Expression arrayConcat(
    @NonNull Expression firstArray,
    @NonNull Object secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates an array with other arrays.

// Combine the 'items' array with another array field.
arrayConcat(field("items"), field("otherItems"))
Parameters
@NonNull Expression firstArray

The first array expression to concatenate to.

@NonNull Object secondArray

An array expression or array literal to concatenate.

@NonNull Object otherArrays

Optional additional array expressions or array literals to concatenate.

Returns
@NonNull Expression

A new Expression representing the arrayConcat operation.

arrayConcat

public static final @NonNull Expression arrayConcat(
    @NonNull Expression firstArray,
    @NonNull Expression secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates an array with other arrays.

// Combine the 'items' array with another array field.
arrayConcat(field("items"), field("otherItems"))
Parameters
@NonNull Expression firstArray

The first array expression to concatenate to.

@NonNull Expression secondArray

An expression that evaluates to array to concatenate.

@NonNull Object otherArrays

Optional additional array expressions or array literals to concatenate.

Returns
@NonNull Expression

A new Expression representing the arrayConcat operation.

arrayConcat

public static final @NonNull Expression arrayConcat(
    @NonNull String firstArrayField,
    @NonNull Object secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates a field's array value with other arrays.

// Combine the 'items' array with a literal array.
arrayConcat("items", listOf("a", "b"))
Parameters
@NonNull String firstArrayField

The name of field that contains first array to concatenate to.

@NonNull Object secondArray

An array expression or array literal to concatenate.

@NonNull Object otherArrays

Optional additional array expressions or array literals to concatenate.

Returns
@NonNull Expression

A new Expression representing the arrayConcat operation.

arrayConcat

public static final @NonNull Expression arrayConcat(
    @NonNull String firstArrayField,
    @NonNull Expression secondArray,
    @NonNull Object otherArrays
)

Creates an expression that concatenates a field's array value with other arrays.

// Combine the 'items' array with another array field.
arrayConcat("items", field("otherItems"))
Parameters
@NonNull String firstArrayField

The name of field that contains first array to concatenate to.

@NonNull Expression secondArray

An expression that evaluates to array to concatenate.

@NonNull Object otherArrays

Optional additional array expressions or array literals to concatenate.

Returns
@NonNull Expression

A new Expression representing the arrayConcat operation.

arrayContains

public static final @NonNull BooleanExpression arrayContains(@NonNull Expression array, @NonNull Object element)

Creates an expression that checks if the array contains a specific element.

// Check if the 'sizes' array contains the value from the 'selectedSize' field
arrayContains(field("sizes"), field("selectedSize"))

// Check if the 'colors' array contains "red"
arrayContains(field("colors"), "red")
Parameters
@NonNull Expression array

The array expression to check.

@NonNull Object element

The element to search for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContains operation.

arrayContains

public static final @NonNull BooleanExpression arrayContains(@NonNull Expression array, @NonNull Expression element)

Creates an expression that checks if the array contains a specific element.

Parameters
@NonNull Expression array

The array expression to check.

@NonNull Expression element

The element to search for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContains operation.

arrayContains

public static final @NonNull BooleanExpression arrayContains(@NonNull String arrayFieldName, @NonNull Object element)

Creates an expression that checks if the array field contains a specific element.

// Check if the 'colors' array contains "red"
arrayContains("colors", "red")
Parameters
@NonNull String arrayFieldName

The name of field that contains array to check.

@NonNull Object element

The element to search for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContains operation.

arrayContains

public static final @NonNull BooleanExpression arrayContains(@NonNull String arrayFieldName, @NonNull Expression element)

Creates an expression that checks if the array field contains a specific element.

// Check if the 'sizes' array contains the value from the 'selectedSize' field
arrayContains("sizes", field("selectedSize"))
Parameters
@NonNull String arrayFieldName

The name of field that contains array to check.

@NonNull Expression element

The element to search for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContains operation.

arrayContainsAll

public static final @NonNull BooleanExpression arrayContainsAll(
    @NonNull Expression array,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array contains all elements of arrayExpression.

// Check if the 'tags' array contains both of the values from field "tag1" and the literal value "tag2"
arrayContainsAll(field("tags"), array(field("tag1"), "tag2"))
Parameters
@NonNull Expression array

The array expression to check.

@NonNull Expression arrayExpression

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAll

public static final @NonNull BooleanExpression arrayContainsAll(
    @NonNull Expression array,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array contains all the specified values.

// Check if the 'tags' array contains both the value in field "tag1" and the literal value "tag2"
arrayContainsAll(field("tags"), listOf(field("tag1"), "tag2"))
Parameters
@NonNull Expression array

The array expression to check.

@NonNull List<@NonNull Object> values

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAll

public static final @NonNull BooleanExpression arrayContainsAll(
    @NonNull String arrayFieldName,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array field contains all elements of arrayExpression.

// Check if the 'permissions' array contains all the required permissions
arrayContainsAll("permissions", field("requiredPermissions"))
Parameters
@NonNull String arrayFieldName

The name of field that contains array to check.

@NonNull Expression arrayExpression

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAll

public static final @NonNull BooleanExpression arrayContainsAll(
    @NonNull String arrayFieldName,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array field contains all the specified values.

// Check if the 'tags' array contains both "internal" and "public"
arrayContainsAll("tags", listOf("internal", "public"))
Parameters
@NonNull String arrayFieldName

The name of field that contains array to check.

@NonNull List<@NonNull Object> values

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAny

public static final @NonNull BooleanExpression arrayContainsAny(
    @NonNull Expression array,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array contains any elements of arrayExpression.

// Check if the 'groups' array contains either the value from the 'userGroup' field
// or the value "guest"
arrayContainsAny(field("groups"), array(field("userGroup"), "guest"))
Parameters
@NonNull Expression array

The array expression to check.

@NonNull Expression arrayExpression

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayContainsAny

public static final @NonNull BooleanExpression arrayContainsAny(
    @NonNull Expression array,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array contains any of the specified values.

// Check if the 'categories' array contains either values from field "cate1" or "cate2"
arrayContainsAny(field("categories"), listOf(field("cate1"), field("cate2")))
Parameters
@NonNull Expression array

The array expression to check.

@NonNull List<@NonNull Object> values

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayContainsAny

public static final @NonNull BooleanExpression arrayContainsAny(
    @NonNull String arrayFieldName,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if array field contains any elements of arrayExpression.

// Check if the 'userGroups' array contains any of the 'targetGroups'
arrayContainsAny("userGroups", field("targetGroups"))
Parameters
@NonNull String arrayFieldName

The name of field that contains array to check.

@NonNull Expression arrayExpression

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayContainsAny

public static final @NonNull BooleanExpression arrayContainsAny(
    @NonNull String arrayFieldName,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if array field contains any of the specified values.

// Check if the 'roles' array contains "admin" or "editor"
arrayContainsAny("roles", listOf("admin", "editor"))
Parameters
@NonNull String arrayFieldName

The name of field that contains array to check.

@NonNull List<@NonNull Object> values

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayGet

public static final @NonNull Expression arrayGet(@NonNull Expression array, @NonNull Expression offset)

Creates an expression that indexes into an array from the beginning or end and return the element. If the offset exceeds the array length, an error is returned. A negative offset, starts from the end.

// Return the value in the tags field array at index specified by field 'favoriteTag'.
arrayGet(field("tags"), field("favoriteTag"))
Parameters
@NonNull Expression array

An Expression evaluating to an array.

@NonNull Expression offset

An Expression evaluating to the index of the element to return.

Returns
@NonNull Expression

A new Expression representing the arrayOffset operation.

arrayGet

public static final @NonNull Expression arrayGet(@NonNull Expression array, int offset)

Creates an expression that indexes into an array from the beginning or end and return the element. If the offset exceeds the array length, an error is returned. A negative offset, starts from the end.

// Return the value in the 'tags' field array at index `1`.
arrayGet(field("tags"), 1)
Parameters
@NonNull Expression array

An Expression evaluating to an array.

int offset

The index of the element to return.

Returns
@NonNull Expression

A new Expression representing the arrayOffset operation.

arrayGet

public static final @NonNull Expression arrayGet(@NonNull String arrayFieldName, @NonNull Expression offset)

Creates an expression that indexes into an array from the beginning or end and return the element. If the offset exceeds the array length, an error is returned. A negative offset, starts from the end.

// Return the value in the tags field array at index specified by field 'favoriteTag'.
arrayGet("tags", field("favoriteTag"))
Parameters
@NonNull String arrayFieldName

The name of an array field.

@NonNull Expression offset

An Expression evaluating to the index of the element to return.

Returns
@NonNull Expression

A new Expression representing the arrayOffset operation.

arrayGet

public static final @NonNull Expression arrayGet(@NonNull String arrayFieldName, int offset)

Creates an expression that indexes into an array from the beginning or end and return the element. If the offset exceeds the array length, an error is returned. A negative offset, starts from the end.

// Return the value in the 'tags' field array at index `1`.
arrayGet("tags", 1)
Parameters
@NonNull String arrayFieldName

The name of an array field.

int offset

The index of the element to return.

Returns
@NonNull Expression

A new Expression representing the arrayOffset operation.

arrayLength

public static final @NonNull Expression arrayLength(@NonNull Expression array)

Creates an expression that calculates the length of an array expression.

// Get the number of items in the 'cart' array
arrayLength(field("cart"))
Parameters
@NonNull Expression array

The array expression to calculate the length of.

Returns
@NonNull Expression

A new Expression representing the length of the array.

arrayLength

public static final @NonNull Expression arrayLength(@NonNull String arrayFieldName)

Creates an expression that calculates the length of an array field.

// Get the number of items in the 'cart' array
arrayLength("cart")
Parameters
@NonNull String arrayFieldName

The name of the field containing an array to calculate the length of.

Returns
@NonNull Expression

A new Expression representing the length of the array.

arrayReverse

public static final @NonNull Expression arrayReverse(@NonNull Expression array)

Reverses the order of elements in the array.

// Reverse the value of the 'myArray' field.
arrayReverse(field("myArray"))
Parameters
@NonNull Expression array

The array expression to reverse.

Returns
@NonNull Expression

A new Expression representing the arrayReverse operation.

arrayReverse

public static final @NonNull Expression arrayReverse(@NonNull String arrayFieldName)

Reverses the order of elements in the array field.

// Reverse the value of the 'myArray' field.
arrayReverse("myArray")
Parameters
@NonNull String arrayFieldName

The name of field that contains the array to reverse.

Returns
@NonNull Expression

A new Expression representing the arrayReverse operation.

arraySum

public static final @NonNull Expression arraySum(@NonNull Expression array)

Creates an expression that returns the sum of the elements in an array.

// Get the sum of elements in the 'scores' array.
arraySum(field("scores"))
Parameters
@NonNull Expression array

The array expression to sum.

Returns
@NonNull Expression

A new Expression representing the sum of the array elements.

arraySum

public static final @NonNull Expression arraySum(@NonNull String arrayFieldName)

Creates an expression that returns the sum of the elements in an array field.

// Get the sum of elements in the 'scores' array.
arraySum("scores")
Parameters
@NonNull String arrayFieldName

The name of the field containing the array to sum.

Returns
@NonNull Expression

A new Expression representing the sum of the array elements.

bitAnd

public static final @NonNull Expression bitAnd(@NonNull Expression bits, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise AND operation between an expression and a constant.

// Bitwise AND the value of the 'flags' field with a constant mask.
bitAnd(field("flags"), byteArrayOf(0b00001111))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise AND operation.

bitAnd

public static final @NonNull Expression bitAnd(@NonNull Expression bits, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise AND operation between two expressions.

// Bitwise AND the value of the 'flags' field with the value of the 'mask' field.
bitAnd(field("flags"), field("mask"))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull Expression bitsOther

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise AND operation.

bitAnd

public static final @NonNull Expression bitAnd(@NonNull String bitsFieldName, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise AND operation between an field and constant.

// Bitwise AND the value of the 'flags' field with a constant mask.
bitAnd("flags", byteArrayOf(0b00001111))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise AND operation.

bitAnd

public static final @NonNull Expression bitAnd(@NonNull String bitsFieldName, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise AND operation between an field and an expression.

// Bitwise AND the value of the 'flags' field with the value of the 'mask' field.
bitAnd("flags", field("mask"))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull Expression bitsOther

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise AND operation.

bitLeftShift

public static final @NonNull Expression bitLeftShift(@NonNull Expression bits, int number)

Creates an expression that applies a bitwise left shift operation between an expression and a constant.

// Left shift the value of the 'bits' field by 2.
bitLeftShift(field("bits"), 2)
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

int number

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise left shift operation.

bitLeftShift

public static final @NonNull Expression bitLeftShift(@NonNull Expression bits, @NonNull Expression numberExpr)

Creates an expression that applies a bitwise left shift operation between two expressions.

// Left shift the value of the 'bits' field by the value of the 'shift' field.
bitLeftShift(field("bits"), field("shift"))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull Expression numberExpr

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise left shift operation.

bitLeftShift

public static final @NonNull Expression bitLeftShift(@NonNull String bitsFieldName, int number)

Creates an expression that applies a bitwise left shift operation between a field and a constant.

// Left shift the value of the 'bits' field by 2.
bitLeftShift("bits", 2)
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

int number

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise left shift operation.

bitLeftShift

public static final @NonNull Expression bitLeftShift(@NonNull String bitsFieldName, @NonNull Expression numberExpr)

Creates an expression that applies a bitwise left shift operation between a field and an expression.

// Left shift the value of the 'bits' field by the value of the 'shift' field.
bitLeftShift("bits", field("shift"))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull Expression numberExpr

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise left shift operation.

bitNot

public static final @NonNull Expression bitNot(@NonNull Expression bits)

Creates an expression that applies a bitwise NOT operation to an expression.

// Bitwise NOT the value of the 'flags' field.
bitNot(field("flags"))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise NOT operation.

bitNot

public static final @NonNull Expression bitNot(@NonNull String bitsFieldName)

Creates an expression that applies a bitwise NOT operation to a field.

// Bitwise NOT the value of the 'flags' field.
bitNot("flags")
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

Returns
@NonNull Expression

A new Expression representing the bitwise NOT operation.

bitOr

public static final @NonNull Expression bitOr(@NonNull Expression bits, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise OR operation between an expression and a constant.

// Bitwise OR the value of the 'flags' field with a constant mask.
bitOr(field("flags"), byteArrayOf(0b00001111))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise OR operation.

bitOr

public static final @NonNull Expression bitOr(@NonNull Expression bits, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise OR operation between two expressions.

// Bitwise OR the value of the 'flags' field with the value of the 'mask' field.
bitOr(field("flags"), field("mask"))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull Expression bitsOther

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise OR operation.

bitOr

public static final @NonNull Expression bitOr(@NonNull String bitsFieldName, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise OR operation between an field and constant.

// Bitwise OR the value of the 'flags' field with a constant mask.
bitOr("flags", byteArrayOf(0b00001111))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise OR operation.

bitOr

public static final @NonNull Expression bitOr(@NonNull String bitsFieldName, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise OR operation between an field and an expression.

// Bitwise OR the value of the 'flags' field with the value of the 'mask' field.
bitOr("flags", field("mask"))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull Expression bitsOther

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise OR operation.

bitRightShift

public static final @NonNull Expression bitRightShift(@NonNull Expression bits, int number)

Creates an expression that applies a bitwise right shift operation between an expression and a constant.

// Right shift the value of the 'bits' field by 2.
bitRightShift(field("bits"), 2)
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

int number

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise right shift operation.

bitRightShift

public static final @NonNull Expression bitRightShift(@NonNull Expression bits, @NonNull Expression numberExpr)

Creates an expression that applies a bitwise right shift operation between two expressions.

// Right shift the value of the 'bits' field by the value of the 'shift' field.
bitRightShift(field("bits"), field("shift"))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull Expression numberExpr

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise right shift operation.

bitRightShift

public static final @NonNull Expression bitRightShift(@NonNull String bitsFieldName, int number)

Creates an expression that applies a bitwise right shift operation between a field and a constant.

// Right shift the value of the 'bits' field by 2.
bitRightShift("bits", 2)
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

int number

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise right shift operation.

bitRightShift

public static final @NonNull Expression bitRightShift(
    @NonNull String bitsFieldName,
    @NonNull Expression numberExpr
)

Creates an expression that applies a bitwise right shift operation between a field and an expression.

// Right shift the value of the 'bits' field by the value of the 'shift' field.
bitRightShift("bits", field("shift"))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull Expression numberExpr

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise right shift operation.

bitXor

public static final @NonNull Expression bitXor(@NonNull Expression bits, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise XOR operation between an expression and a constant.

// Bitwise XOR the value of the 'flags' field with a constant mask.
bitXor(field("flags"), byteArrayOf(0b00001111))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise XOR operation.

bitXor

public static final @NonNull Expression bitXor(@NonNull Expression bits, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise XOR operation between two expressions.

// Bitwise XOR the value of the 'flags' field with the value of the 'mask' field.
bitXor(field("flags"), field("mask"))
Parameters
@NonNull Expression bits

An expression that returns bits when evaluated.

@NonNull Expression bitsOther

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise XOR operation.

bitXor

public static final @NonNull Expression bitXor(@NonNull String bitsFieldName, @NonNull byte[] bitsOther)

Creates an expression that applies a bitwise XOR operation between an field and constant.

// Bitwise XOR the value of the 'flags' field with a constant mask.
bitXor("flags", byteArrayOf(0b00001111))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise XOR operation.

bitXor

public static final @NonNull Expression bitXor(@NonNull String bitsFieldName, @NonNull Expression bitsOther)

Creates an expression that applies a bitwise XOR operation between an field and an expression.

// Bitwise XOR the value of the 'flags' field with the value of the 'mask' field.
bitXor("flags", field("mask"))
Parameters
@NonNull String bitsFieldName

Name of field that contains bits data.

@NonNull Expression bitsOther

An expression that returns bits when evaluated.

Returns
@NonNull Expression

A new Expression representing the bitwise XOR operation.

byteLength

public static final @NonNull Expression byteLength(@NonNull String fieldName)

Creates an expression that calculates the length of a string represented by a field in UTF-8 bytes, or just the length of a Blob.

// Calculate the length of the 'myString' field in bytes.
byteLength("myString")
Parameters
@NonNull String fieldName

The name of the field containing the string.

Returns
@NonNull Expression

A new Expression representing the length of the string in bytes.

byteLength

public static final @NonNull Expression byteLength(@NonNull Expression value)

Creates an expression that calculates the length of a string in UTF-8 bytes, or just the length of a Blob.

// Calculate the length of the 'myString' field in bytes.
byteLength("myString")
Parameters
@NonNull Expression value

The expression representing the string.

Returns
@NonNull Expression

A new Expression representing the length of the string in bytes.

ceil

public static final @NonNull Expression ceil(@NonNull Expression numericExpr)

Creates an expression that returns the smallest integer that isn't less than numericExpr.

// Compute the ceiling of the 'price' field.
ceil(field("price"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing an integer result from the ceil operation.

ceil

public static final @NonNull Expression ceil(@NonNull String numericField)

Creates an expression that returns the smallest integer that isn't less than numericField.

// Compute the ceiling of the 'price' field.
ceil("price")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing an integer result from the ceil operation.

charLength

public static final @NonNull Expression charLength(@NonNull Expression expr)

Creates an expression that calculates the character length of a string expression in UTF8.

// Get the character length of the 'name' field in UTF-8.
charLength("name")
Parameters
@NonNull Expression expr

The expression representing the string.

Returns
@NonNull Expression

A new Expression representing the charLength operation.

charLength

public static final @NonNull Expression charLength(@NonNull String fieldName)

Creates an expression that calculates the character length of a string field in UTF8.

// Get the character length of the 'name' field in UTF-8.
charLength("name")
Parameters
@NonNull String fieldName

The name of the field containing the string.

Returns
@NonNull Expression

A new Expression representing the charLength operation.

collectionId

public static final @NonNull Expression collectionId(@NonNull Expression path)

Creates an expression that returns the collection ID from a path.

// Get the collection ID from the 'path' field
collectionId(field("path"))
Parameters
@NonNull Expression path

An expression the evaluates to a path.

Returns
@NonNull Expression

A new Expression representing the collectionId operation.

collectionId

public static final @NonNull Expression collectionId(@NonNull String pathField)

Creates an expression that returns the collection ID from a path.

// Get the collection ID from a path field
collectionId("pathField")
Parameters
@NonNull String pathField

The string representation of the path.

Returns
@NonNull Expression

A new Expression representing the collectionId operation.

concat

public static final @NonNull Expression concat(
    @NonNull Expression first,
    @NonNull Object second,
    @NonNull Object others
)

Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.

// Concatenate a field with a literal string.
concat(field("firstName"), "Doe")
Parameters
@NonNull Expression first

The first expression to concatenate.

@NonNull Object second

The second value to concatenate.

@NonNull Object others

Additional values to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenation.

concat

public static final @NonNull Expression concat(
    @NonNull Expression first,
    @NonNull Expression second,
    @NonNull Object others
)

Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.

// Concatenate the 'firstName' and 'lastName' fields with a space in between.
concat(field("firstName"), " ", field("lastName"))
Parameters
@NonNull Expression first

The first expression to concatenate.

@NonNull Expression second

The second expression to concatenate.

@NonNull Object others

Additional expressions to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenation.

concat

public static final @NonNull Expression concat(@NonNull String first, @NonNull Object second, @NonNull Object others)

Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.

// Concatenate a field name with a literal string.
concat("firstName", "Doe")
Parameters
@NonNull String first

The name of the field containing the first value to concatenate.

@NonNull Object second

The second value to concatenate.

@NonNull Object others

Additional values to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenation.

concat

public static final @NonNull Expression concat(
    @NonNull String first,
    @NonNull Expression second,
    @NonNull Object others
)

Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed.

// Concatenate a field name with an expression.
concat("firstName", field("lastName"))
Parameters
@NonNull String first

The name of the field containing the first value to concatenate.

@NonNull Expression second

The second expression to concatenate.

@NonNull Object others

Additional expressions to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenation.

conditional

public static final @NonNull Expression conditional(
    @NonNull BooleanExpression condition,
    @NonNull Expression thenExpr,
    @NonNull Expression elseExpr
)

Creates a conditional expression that evaluates to a thenExpr expression if a condition is true or an elseExpr expression if the condition is false.

Parameters
@NonNull BooleanExpression condition

The condition to evaluate.

@NonNull Expression thenExpr

The expression to evaluate if the condition is true.

@NonNull Expression elseExpr

The expression to evaluate if the condition is false.

Returns
@NonNull Expression

A new Expression representing the conditional operation.

conditional

public static final @NonNull Expression conditional(
    @NonNull BooleanExpression condition,
    @NonNull Object thenValue,
    @NonNull Object elseValue
)

Creates a conditional expression that evaluates to a thenValue if a condition is true or an elseValue if the condition is false.

// If the 'quantity' field is greater than 10, return "High", otherwise return "Low"
conditional(field("quantity").greaterThan(10), "High", "Low")
Parameters
@NonNull BooleanExpression condition

The condition to evaluate.

@NonNull Object thenValue

Value if the condition is true.

@NonNull Object elseValue

Value if the condition is false.

Returns
@NonNull Expression

A new Expression representing the conditional operation.

constant

public static final @NonNull Expression constant(@NonNull DocumentReference ref)

Create a constant for a DocumentReference value.

// val firestore = FirebaseFirestore.getInstance()
// val docRef = firestore.collection("cities").document("SF")
// constant(docRef)
Parameters
@NonNull DocumentReference ref

The DocumentReference value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull Blob value)

Create a constant for a Blob value.

// Create a constant with a Blob
constant
(Blob.fromBytes(byteArrayOf(0x48, 0x65, 0x6c, 0x6c, 0x6f))) // "Hello"
Parameters
@NonNull Blob value

The Blob value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull BooleanExpression constant(boolean value)

Create a constant for a Boolean value.

// Create a constant with the value true
constant
(true)
Parameters
boolean value

The Boolean value.

Returns
@NonNull BooleanExpression

A new BooleanExpression constant instance.

constant

public static final @NonNull Expression constant(@NonNull byte[] value)

Create a constant for a bytes value.

// Create a constant with a byte array
constant
(byteArrayOf(0x48, 0x65, 0x6c, 0x6c, 0x6f)) // "Hello"
Parameters
@NonNull byte[] value

The bytes value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull Date value)

Create a constant for a Date value.

// Create a constant with the current date
constant
(Date())
Parameters
@NonNull Date value

The Date value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull GeoPoint value)

Create a constant for a GeoPoint value.

// Create a constant with a GeoPoint
constant
(GeoPoint(37.7749, -122.4194))
Parameters
@NonNull GeoPoint value

The GeoPoint value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull Number value)

Create a constant for a Number value.

// Create a constant with the value 123
constant(123)
Parameters
@NonNull Number value

The Number value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull String value)

Create a constant for a String value.

// Create a constant with the value "hello"
constant("hello")
Parameters
@NonNull String value

The String value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull Timestamp value)

Create a constant for a Timestamp value.

// Create a constant with the current timestamp
constant
(Timestamp.now())
Parameters
@NonNull Timestamp value

The Timestamp value.

Returns
@NonNull Expression

A new Expression constant instance.

constant

public static final @NonNull Expression constant(@NonNull VectorValue value)

Create a constant for a VectorValue value.

// Create a constant with a VectorValue
constant
(VectorValue(listOf(1.0, 2.0, 3.0)))
Parameters
@NonNull VectorValue value

The VectorValue value.

Returns
@NonNull Expression

A new Expression constant instance.

cosineDistance

public static final @NonNull Expression cosineDistance(@NonNull Expression vector1, @NonNull double[] vector2)

Calculates the Cosine distance between vector expression and a vector literal.

// Calculate the Cosine distance between the 'location' field and a target location
cosineDistance(field("location"), doubleArrayOf(37.7749, -122.4194))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull double[] vector2

The other vector (as an array of doubles) to compare against.

Returns
@NonNull Expression

A new Expression representing the cosine distance between the two vectors.

cosineDistance

public static final @NonNull Expression cosineDistance(@NonNull Expression vector1, @NonNull Expression vector2)

Calculates the Cosine distance between two vector expressions.

// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field
cosineDistance(field("userVector"), field("itemVector"))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull Expression vector2

The other vector (represented as an Expression) to compare against.

Returns
@NonNull Expression

A new Expression representing the cosine distance between the two vectors.

cosineDistance

public static final @NonNull Expression cosineDistance(@NonNull Expression vector1, @NonNull VectorValue vector2)

Calculates the Cosine distance between vector expression and a vector literal.

// Calculate the Cosine distance between the 'location' field and a target location
cosineDistance(field("location"), VectorValue.from(listOf(37.7749, -122.4194)))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull VectorValue vector2

The other vector (represented as an VectorValue) to compare against.

Returns
@NonNull Expression

A new Expression representing the cosine distance between the two vectors.

cosineDistance

public static final @NonNull Expression cosineDistance(@NonNull String vectorFieldName, @NonNull double[] vector)

Calculates the Cosine distance between a vector field and a vector literal.

// Calculate the Cosine distance between the 'location' field and a target location
cosineDistance("location", doubleArrayOf(37.7749, -122.4194))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull double[] vector

The other vector (as an array of doubles) to compare against.

Returns
@NonNull Expression

A new Expression representing the cosine distance between the two vectors.

cosineDistance

public static final @NonNull Expression cosineDistance(@NonNull String vectorFieldName, @NonNull Expression vector)

Calculates the Cosine distance between a vector field and a vector expression.

// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field
cosineDistance("userVector", field("itemVector"))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull Expression vector

The other vector (represented as an Expression) to compare against.

Returns
@NonNull Expression

A new Expression representing the cosine distance between the two vectors.

cosineDistance

public static final @NonNull Expression cosineDistance(
    @NonNull String vectorFieldName,
    @NonNull VectorValue vector
)

Calculates the Cosine distance between a vector field and a vector literal.

// Calculate the Cosine distance between the 'location' field and a target location
cosineDistance("location", VectorValue.from(listOf(37.7749, -122.4194)))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull VectorValue vector

The other vector (represented as an VectorValue) to compare against.

Returns
@NonNull Expression

A new Expression representing the cosine distance between the two vectors.

currentTimestamp

public static final @NonNull Expression currentTimestamp()

Creates an expression that evaluates to the current server timestamp.

// Get the current server timestamp
currentTimestamp()
Returns
@NonNull Expression

A new Expression representing the current server timestamp.

divide

public static final @NonNull Expression divide(@NonNull Expression dividend, @NonNull Expression divisor)

Creates an expression that divides two numeric expressions.

// Divide the 'total' field by the 'count' field
divide(field("total"), field("count"))
Parameters
@NonNull Expression dividend

The numeric expression to be divided.

@NonNull Expression divisor

The numeric expression to divide by.

Returns
@NonNull Expression

A new Expression representing the division operation.

divide

public static final @NonNull Expression divide(@NonNull Expression dividend, @NonNull Number divisor)

Creates an expression that divides a numeric expression by a constant.

// Divide the 'value' field by 10
divide(field("value"), 10)
Parameters
@NonNull Expression dividend

The numeric expression to be divided.

@NonNull Number divisor

The constant to divide by.

Returns
@NonNull Expression

A new Expression representing the division operation.

divide

public static final @NonNull Expression divide(@NonNull String dividendFieldName, @NonNull Expression divisor)

Creates an expression that divides numeric field by a numeric expression.

// Divide the 'total' field by the 'count' field.
divide("total", field("count"))
Parameters
@NonNull String dividendFieldName

The numeric field name to be divided.

@NonNull Expression divisor

The numeric expression to divide by.

Returns
@NonNull Expression

A new Expression representing the divide operation.

divide

public static final @NonNull Expression divide(@NonNull String dividendFieldName, @NonNull Number divisor)

Creates an expression that divides a numeric field by a constant.

// Divide the 'total' field by 2.
divide("total", 2)
Parameters
@NonNull String dividendFieldName

The numeric field name to be divided.

@NonNull Number divisor

The constant to divide by.

Returns
@NonNull Expression

A new Expression representing the divide operation.

documentId

public static final @NonNull Expression documentId(@NonNull DocumentReference docRef)

Creates an expression that returns the document ID from a DocumentReference.

Parameters
@NonNull DocumentReference docRef

The DocumentReference.

Returns
@NonNull Expression

A new Expression representing the documentId operation.

documentId

public static final @NonNull Expression documentId(@NonNull Expression documentPath)

Creates an expression that returns the document ID from a path.

// Get the document ID from the 'path' field
documentId(field("path"))
Parameters
@NonNull Expression documentPath

An expression the evaluates to document path.

Returns
@NonNull Expression

A new Expression representing the documentId operation.

documentId

public static final @NonNull Expression documentId(@NonNull String documentPath)

Creates an expression that returns the document ID from a path.

// Get the document ID from a path string
documentId("projects/p/databases/d/documents/c/d")
Parameters
@NonNull String documentPath

The string representation of the document path.

Returns
@NonNull Expression

A new Expression representing the documentId operation.

dotProduct

public static final @NonNull Expression dotProduct(@NonNull Expression vector1, @NonNull double[] vector2)

Calculates the dot product distance between vector expression and a vector literal.

// Calculate the dot product between the 'vector' field and a constant vector
dotProduct
(field("vector"), doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull double[] vector2

The other vector (as an array of doubles) to compare against.

Returns
@NonNull Expression

A new Expression representing the dot product distance between the two vectors.

dotProduct

public static final @NonNull Expression dotProduct(@NonNull Expression vector1, @NonNull Expression vector2)

Calculates the dot product distance between two vector expressions.

// Calculate the dot product between the 'userVector' field and the 'itemVector' field
dotProduct(field("userVector"), field("itemVector"))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull Expression vector2

The other vector (represented as an Expression) to compare against.

Returns
@NonNull Expression

A new Expression representing the dot product distance between the two vectors.

dotProduct

public static final @NonNull Expression dotProduct(@NonNull Expression vector1, @NonNull VectorValue vector2)

Calculates the dot product distance between vector expression and a vector literal.

// Calculate the dot product between the 'vector' field and a constant vector
dotProduct
(field("vector"), VectorValue.from(listOf(1.0, 2.0, 3.0)))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull VectorValue vector2

The other vector (represented as an VectorValue) to compare against.

Returns
@NonNull Expression

A new Expression representing the dot product distance between the two vectors.

dotProduct

public static final @NonNull Expression dotProduct(@NonNull String vectorFieldName, @NonNull double[] vector)

Calculates the dot product distance between vector field and a vector literal.

// Calculate the dot product between the 'vector' field and a constant vector
dotProduct
("vector", doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull double[] vector

The other vector (as an array of doubles) to compare against.

Returns
@NonNull Expression

A new Expression representing the dot product distance between the two vectors.

dotProduct

public static final @NonNull Expression dotProduct(@NonNull String vectorFieldName, @NonNull Expression vector)

Calculates the dot product distance between a vector field and a vector expression.

// Calculate the dot product between the 'userVector' field and the 'itemVector' field
dotProduct("userVector", field("itemVector"))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull Expression vector

The other vector (represented as an Expression) to compare against.

Returns
@NonNull Expression

A new Expression representing the dot product distance between the two vectors.

dotProduct

public static final @NonNull Expression dotProduct(@NonNull String vectorFieldName, @NonNull VectorValue vector)

Calculates the dot product distance between a vector field and a vector literal.

// Calculate the dot product between the 'vector' field and a constant vector
dotProduct
("vector", VectorValue.from(listOf(1.0, 2.0, 3.0)))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull VectorValue vector

The other vector (represented as an VectorValue) to compare against.

Returns
@NonNull Expression

A new Expression representing the dot product distance between the two vectors.

endsWith

public static final @NonNull BooleanExpression endsWith(@NonNull String fieldName, @NonNull Expression suffix)

Creates an expression that checks if a string expression ends with a given suffix.

// Check if the 'url' field ends with the value of the 'extension' field
endsWith("url", field("extension"))
Parameters
@NonNull String fieldName

The name of field that contains a string to check.

@NonNull Expression suffix

The suffix string expression to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith

public static final @NonNull BooleanExpression endsWith(@NonNull String fieldName, @NonNull String suffix)

Creates an expression that checks if a string expression ends with a given suffix.

// Check if the 'filename' field ends with ".txt"
endsWith("filename", ".txt")
Parameters
@NonNull String fieldName

The name of field that contains a string to check.

@NonNull String suffix

The suffix string to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith

public static final @NonNull BooleanExpression endsWith(@NonNull Expression stringExpr, @NonNull Expression suffix)

Creates an expression that checks if a string expression ends with a given suffix.

// Check if the 'url' field ends with the value of the 'extension' field
endsWith(field("url"), field("extension"))
Parameters
@NonNull Expression stringExpr

The expression to check.

@NonNull Expression suffix

The suffix string expression to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith

public static final @NonNull BooleanExpression endsWith(@NonNull Expression stringExpr, @NonNull String suffix)

Creates an expression that checks if a string expression ends with a given suffix.

// Check if the 'filename' field ends with ".txt"
endsWith(field("filename"), ".txt")
Parameters
@NonNull Expression stringExpr

The expression to check.

@NonNull String suffix

The suffix string to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

equal

public static final @NonNull BooleanExpression equal(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is equal to an expression.

// Check if the 'age' field is equal to the 'limit' field
equal("age", field("limit"))
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Expression expression

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the equality comparison.

equal

public static final @NonNull BooleanExpression equal(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is equal to another value.

// Check if the 'city' field is equal to string constant "London"
equal("city", "London")
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Object value

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the equality comparison.

equal

public static final @NonNull BooleanExpression equal(@NonNull Expression left, @NonNull Object right)

Creates an expression that checks if an expression is equal to a value.

// Check if the 'age' field is equal to 21
equal(field("age"), 21)
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Object right

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the equality comparison.

equal

public static final @NonNull BooleanExpression equal(@NonNull Expression left, @NonNull Expression right)

Creates an expression that checks if two expressions are equal.

// Check if the 'age' field is equal to an expression
equal(field("age"), field("minAge").add(10))
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Expression right

The second expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the equality comparison.

equalAny

public static final @NonNull BooleanExpression equalAny(
    @NonNull Expression expression,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if an expression, when evaluated, is equal to any of the elements of arrayExpression.

// Check if the 'category' field is in the 'availableCategories' array field.
equalAny(field("category"), field("availableCategories"))
Parameters
@NonNull Expression expression

The expression whose results to compare.

@NonNull Expression arrayExpression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

equalAny

public static final @NonNull BooleanExpression equalAny(
    @NonNull Expression expression,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if an expression, when evaluated, is equal to any of the provided values.

// Check if the 'category' field is either "Electronics" or the value of the 'primaryType' field.
equalAny(field("category"), listOf("Electronics", field("primaryType")))
Parameters
@NonNull Expression expression

The expression whose results to compare.

@NonNull List<@NonNull Object> values

The values to check against.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

equalAny

public static final @NonNull BooleanExpression equalAny(@NonNull String fieldName, @NonNull Expression arrayExpression)

Creates an expression that checks if a field's value is equal to any of the elements of arrayExpression.

// Check if the 'category' field is in the 'availableCategories' array field.
equalAny("category", field("availableCategories"))
Parameters
@NonNull String fieldName

The field to compare.

@NonNull Expression arrayExpression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

equalAny

public static final @NonNull BooleanExpression equalAny(@NonNull String fieldName, @NonNull List<@NonNull Object> values)

Creates an expression that checks if a field's value is equal to any of the provided values .

// Check if the 'category' field is either "Electronics" or "Apparel".
equalAny("category", listOf("Electronics", "Apparel"))
Parameters
@NonNull String fieldName

The field to compare.

@NonNull List<@NonNull Object> values

The values to check against.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

euclideanDistance

public static final @NonNull Expression euclideanDistance(@NonNull Expression vector1, @NonNull double[] vector2)

Calculates the Euclidean distance between vector expression and a vector literal.

// Calculate the Euclidean distance between the 'vector' field and a constant vector
euclideanDistance
(field("vector"), doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull double[] vector2

The other vector (as an array of doubles) to compare against.

Returns
@NonNull Expression

A new Expression representing the Euclidean distance between the two vectors.

euclideanDistance

public static final @NonNull Expression euclideanDistance(@NonNull Expression vector1, @NonNull Expression vector2)

Calculates the Euclidean distance between two vector expressions.

// Calculate the Euclidean distance between the 'userVector' field and the 'itemVector' field
euclideanDistance(field("userVector"), field("itemVector"))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull Expression vector2

The other vector (represented as an Expression) to compare against.

Returns
@NonNull Expression

A new Expression representing the Euclidean distance between the two vectors.

euclideanDistance

public static final @NonNull Expression euclideanDistance(
    @NonNull Expression vector1,
    @NonNull VectorValue vector2
)

Calculates the Euclidean distance between vector expression and a vector literal.

// Calculate the Euclidean distance between the 'vector' field and a constant vector
euclideanDistance
(field("vector"), VectorValue.from(listOf(1.0, 2.0, 3.0)))
Parameters
@NonNull Expression vector1

The first vector (represented as an Expression) to compare against.

@NonNull VectorValue vector2

The other vector (represented as an VectorValue) to compare against.

Returns
@NonNull Expression

A new Expression representing the Euclidean distance between the two vectors.

euclideanDistance

public static final @NonNull Expression euclideanDistance(
    @NonNull String vectorFieldName,
    @NonNull double[] vector
)

Calculates the Euclidean distance between a vector field and a vector literal.

// Calculate the Euclidean distance between the 'vector' field and a constant vector
euclideanDistance
("vector", doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull double[] vector

The other vector (as an array of doubles) to compare against.

Returns
@NonNull Expression

A new Expression representing the Euclidean distance between the two vectors.

euclideanDistance

public static final @NonNull Expression euclideanDistance(
    @NonNull String vectorFieldName,
    @NonNull Expression vector
)

Calculates the Euclidean distance between a vector field and a vector expression.

// Calculate the Euclidean distance between the 'userVector' field and the 'itemVector' field
euclideanDistance("userVector", field("itemVector"))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull Expression vector

The other vector (represented as an Expression) to compare against.

Returns
@NonNull Expression

A new Expression representing the Euclidean distance between the two vectors.

euclideanDistance

public static final @NonNull Expression euclideanDistance(
    @NonNull String vectorFieldName,
    @NonNull VectorValue vector
)

Calculates the Euclidean distance between a vector field and a vector literal.

// Calculate the Euclidean distance between the 'vector' field and a constant vector
euclideanDistance
("vector", VectorValue.from(listOf(1.0, 2.0, 3.0)))
Parameters
@NonNull String vectorFieldName

The name of the field containing the first vector.

@NonNull VectorValue vector

The other vector (represented as an VectorValue) to compare against.

Returns
@NonNull Expression

A new Expression representing the Euclidean distance between the two vectors.

exists

public static final @NonNull BooleanExpression exists(@NonNull String fieldName)

Creates an expression that checks if a field exists.

Parameters
@NonNull String fieldName

The field name to check.

Returns
@NonNull BooleanExpression

A new Expression representing the exists check.

exists

public static final @NonNull BooleanExpression exists(@NonNull Expression value)

Creates an expression that checks if a field exists.

Parameters
@NonNull Expression value

An expression evaluates to the name of the field to check.

Returns
@NonNull BooleanExpression

A new Expression representing the exists check.

exp

public static final @NonNull Expression exp(@NonNull Expression numericExpr)

Creates an expression that returns Euler's number e raised to the power of numericExpr.

// Compute e to the power of the 'value' field.
exp(field("value"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the exponentiation.

exp

public static final @NonNull Expression exp(@NonNull String numericField)

Creates an expression that returns Euler's number e raised to the power of numericField.

// Compute e to the power of the 'value' field.
exp("value")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the exponentiation.

field

public static final @NonNull Field field(@NonNull FieldPath fieldPath)

Creates a Field instance representing the field at the given path.

The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city").

// Get the 'address.city' field
field(FieldPath.of("address", "city"))
Parameters
@NonNull FieldPath fieldPath

The FieldPath to the field.

Returns
@NonNull Field

A new Field instance representing the specified path.

field

public static final @NonNull Field field(@NonNull String name)

Creates a Field instance representing the field at the given path.

The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field (e.g., "address.city").

Parameters
@NonNull String name

The path to the field.

Returns
@NonNull Field

A new Field instance representing the specified path.

floor

public static final @NonNull Expression floor(@NonNull Expression numericExpr)

Creates an expression that returns the largest integer that is not greater than numericExpr

// Compute the floor of the 'price' field.
floor(field("price"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing an integer result from the floor operation.

floor

public static final @NonNull Expression floor(@NonNull String numericField)

Creates an expression that returns the largest integer that is not greater than numericField.

// Compute the floor of the 'price' field.
floor("price")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing an integer result from the floor operation.

greaterThan

public static final @NonNull BooleanExpression greaterThan(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is greater than an expression.

// Check if the 'age' field is greater than the 'limit' field
greaterThan("age", field("limit"))
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Expression expression

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThan

public static final @NonNull BooleanExpression greaterThan(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is greater than another value.

// Check if the 'price' field is greater than 100
greaterThan("price", 100)
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Object value

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThan

public static final @NonNull BooleanExpression greaterThan(@NonNull Expression left, @NonNull Object right)

Creates an expression that checks if an expression is greater than a value.

// Check if the 'price' field is greater than 100
greaterThan(field("price"), 100)
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Object right

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThan

public static final @NonNull BooleanExpression greaterThan(@NonNull Expression left, @NonNull Expression right)

Creates an expression that checks if the first expression is greater than the second expression.

// Check if the 'age' field is greater than the 'limit' field
greaterThan(field("age"), field("limit"))
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Expression right

The second expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThanOrEqual

public static final @NonNull BooleanExpression greaterThanOrEqual(
    @NonNull String fieldName,
    @NonNull Expression expression
)

Creates an expression that checks if a field's value is greater than or equal to an expression.

// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1
greaterThanOrEqual("quantity", field("requirement").add(1))
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Expression expression

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

greaterThanOrEqual

public static final @NonNull BooleanExpression greaterThanOrEqual(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is greater than or equal to another value.

// Check if the 'score' field is greater than or equal to 80
greaterThanOrEqual("score", 80)
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Object value

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

greaterThanOrEqual

public static final @NonNull BooleanExpression greaterThanOrEqual(@NonNull Expression left, @NonNull Object right)

Creates an expression that checks if an expression is greater than or equal to a value.

// Check if the 'score' field is greater than or equal to 80
greaterThanOrEqual(field("score"), 80)
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Object right

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

greaterThanOrEqual

public static final @NonNull BooleanExpression greaterThanOrEqual(@NonNull Expression left, @NonNull Expression right)

Creates an expression that checks if the first expression is greater than or equal to the second expression.

// Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1
greaterThanOrEqual(field("quantity"), field("requirement").add(1))
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Expression right

The second expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

ifAbsent

public static final @NonNull Expression ifAbsent(@NonNull Expression ifExpr, @NonNull Expression elseExpr)

Creates an expression that returns the elseExpr argument if ifExpr is absent, else return the result of the ifExpr argument evaluation.

// Returns the value of the optional field 'optional_field', or returns 'default_value'
// if the field is absent.
ifAbsent(field("optional_field"), "default_value")
Parameters
@NonNull Expression ifExpr

The expression to check for absence.

@NonNull Expression elseExpr

The expression that will be evaluated and returned if ifExpr is absent.

Returns
@NonNull Expression

A new Expression representing the ifAbsent operation.

ifAbsent

public static final @NonNull Expression ifAbsent(@NonNull Expression ifExpr, @NonNull Object elseValue)

Creates an expression that returns the elseValue argument if ifExpr is absent, else return the result of the ifExpr argument evaluation.

// Returns the value of the optional field 'optional_field', or returns 'default_value'
// if the field is absent.
ifAbsent(field("optional_field"), "default_value")
Parameters
@NonNull Expression ifExpr

The expression to check for absence.

@NonNull Object elseValue

The value that will be returned if ifExpr is absent.

Returns
@NonNull Expression

A new Expression representing the ifAbsent operation.

ifAbsent

public static final @NonNull Expression ifAbsent(@NonNull String ifFieldName, @NonNull Expression elseExpr)

Creates an expression that returns the elseExpr argument if ifFieldName is absent, else return the value of the field.

// Returns the value of the optional field 'optional_field', or returns the value of
// 'default_field' if 'optional_field' is absent.
ifAbsent("optional_field", field("default_field"))
Parameters
@NonNull String ifFieldName

The field to check for absence.

@NonNull Expression elseExpr

The expression that will be evaluated and returned if ifFieldName is absent.

Returns
@NonNull Expression

A new Expression representing the ifAbsent operation.

ifAbsent

public static final @NonNull Expression ifAbsent(@NonNull String ifFieldName, @NonNull Object elseValue)

Creates an expression that returns the elseValue argument if ifFieldName is absent, else return the value of the field.

// Returns the value of the optional field 'optional_field', or returns 'default_value'
// if the field is absent.
ifAbsent("optional_field", "default_value")
Parameters
@NonNull String ifFieldName

The field to check for absence.

@NonNull Object elseValue

The value that will be returned if ifFieldName is absent.

Returns
@NonNull Expression

A new Expression representing the ifAbsent operation.

ifError

public static final @NonNull BooleanExpression ifError(
    @NonNull BooleanExpression tryExpr,
    @NonNull BooleanExpression catchExpr
)

Creates an expression that returns the catchExpr argument if there is an error, else return the result of the tryExpr argument evaluation.

This overload will return BooleanExpression when both parameters are also BooleanExpression.

// Returns the result of the boolean expression, or false if it errors.
ifError(field("is_premium"), false)
Parameters
@NonNull BooleanExpression tryExpr

The try boolean expression.

@NonNull BooleanExpression catchExpr

The catch boolean expression that will be evaluated and returned if the tryExpr produces an error.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the ifError operation.

ifError

public static final @NonNull Expression ifError(@NonNull Expression tryExpr, @NonNull Expression catchExpr)

Creates an expression that returns the catchExpr argument if there is an error, else return the result of the tryExpr argument evaluation.

// Returns the first item in the title field arrays, or returns
// the entire title field if the array is empty or the field is another type.
ifError(arrayGet(field("title"), 0), field("title"))
Parameters
@NonNull Expression tryExpr

The try expression.

@NonNull Expression catchExpr

The catch expression that will be evaluated and returned if the tryExpr produces an error.

Returns
@NonNull Expression

A new Expression representing the ifError operation.

ifError

public static final @NonNull Expression ifError(@NonNull Expression tryExpr, @NonNull Object catchValue)

Creates an expression that returns the catchValue argument if there is an error, else return the result of the tryExpr argument evaluation.

// Returns the first item in the title field arrays, or returns "Default Title"
ifError(arrayGet(field("title"), 0), "Default Title")
Parameters
@NonNull Expression tryExpr

The try expression.

@NonNull Object catchValue

The value that will be returned if the tryExpr produces an error.

Returns
@NonNull Expression

A new Expression representing the ifError operation.

isAbsent

public static final @NonNull BooleanExpression isAbsent(@NonNull String fieldName)

Creates an expression that returns true if a field is absent. Otherwise, returns false even if the field value is null.

// Check if the field `value` is absent.
isAbsent("value")
Parameters
@NonNull String fieldName

The field to check.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the isAbsent operation.

isAbsent

public static final @NonNull BooleanExpression isAbsent(@NonNull Expression value)

Creates an expression that returns true if a value is absent. Otherwise, returns false even if the value is null.

// Check if the field `value` is absent.
isAbsent(field("value"))
Parameters
@NonNull Expression value

The expression to check.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the isAbsent operation.

isError

public static final @NonNull BooleanExpression isError(@NonNull Expression expr)

Creates an expression that checks if a given expression produces an error.

// Check if the result of a calculation is an error
isError(arrayContains(field("title"), 1))
Parameters
@NonNull Expression expr

The expression to check.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the isError check.

join

public static final @NonNull Expression join(@NonNull Expression arrayExpression, @NonNull String delimiter)

Creates an expression that joins the elements of an array into a string.

// Join the elements of the 'tags' field with a comma and space.
join(field("tags"), ", ")
Parameters
@NonNull Expression arrayExpression

The expression that evaluates to an array.

@NonNull String delimiter

The string to use as a delimiter.

Returns
@NonNull Expression

A new Expression representing the join operation.

join

public static final @NonNull Expression join(
    @NonNull Expression arrayExpression,
    @NonNull Expression delimiterExpression
)

Creates an expression that joins the elements of an array into a string.

// Join the elements of the 'tags' field with the delimiter from the 'separator' field.
join(field("tags"), field("separator"))
Parameters
@NonNull Expression arrayExpression

The expression that evaluates to an array.

@NonNull Expression delimiterExpression

The expression that evaluates to the delimiter string.

Returns
@NonNull Expression

A new Expression representing the join operation.

join

public static final @NonNull Expression join(@NonNull String arrayFieldName, @NonNull String delimiter)

Creates an expression that joins the elements of an array field into a string.

// Join the elements of the 'tags' field with a comma and space.
join("tags", ", ")
Parameters
@NonNull String arrayFieldName

The name of the field containing the array.

@NonNull String delimiter

The string to use as a delimiter.

Returns
@NonNull Expression

A new Expression representing the join operation.

join

public static final @NonNull Expression join(
    @NonNull String arrayFieldName,
    @NonNull Expression delimiterExpression
)

Creates an expression that joins the elements of an array field into a string.

// Join the elements of the 'tags' field with the delimiter from the 'separator' field.
join("tags", field("separator"))
Parameters
@NonNull String arrayFieldName

The name of the field containing the array.

@NonNull Expression delimiterExpression

The expression that evaluates to the delimiter string.

Returns
@NonNull Expression

A new Expression representing the join operation.

length

public static final @NonNull Expression length(@NonNull Expression expr)

Creates an expression that calculates the length of a string, array, map, vector, or blob expression.

// Get the length of the 'value' field where the value type can be any of a string, array, map, vector or blob.
length(field("value"))
Parameters
@NonNull Expression expr

The expression representing the string.

Returns
@NonNull Expression

A new Expression representing the length operation.

length

public static final @NonNull Expression length(@NonNull String fieldName)

Creates an expression that calculates the length of a string, array, map, vector, or blob field.

// Get the length of the 'value' field where the value type can be any of a string, array, map, vector or blob.
charLength("value")
Parameters
@NonNull String fieldName

The name of the field containing the string.

Returns
@NonNull Expression

A new Expression representing the length operation.

lessThan

public static final @NonNull BooleanExpression lessThan(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is less than an expression.

// Check if the 'age' field is less than 'limit'
lessThan("age", field("limit"))
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Expression expression

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThan

public static final @NonNull BooleanExpression lessThan(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is less than another value.

// Check if the 'price' field is less than 50
lessThan("price", 50)
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Object value

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThan

public static final @NonNull BooleanExpression lessThan(@NonNull Expression left, @NonNull Object right)

Creates an expression that checks if an expression is less than a value.

// Check if the 'price' field is less than 50
lessThan(field("price"), 50)
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Object right

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThan

public static final @NonNull BooleanExpression lessThan(@NonNull Expression left, @NonNull Expression right)

Creates an expression that checks if the first expression is less than the second expression.

// Check if the 'age' field is less than 'limit'
lessThan(field("age"), field("limit"))
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Expression right

The second expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThanOrEqual

public static final @NonNull BooleanExpression lessThanOrEqual(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is less than or equal to an expression.

// Check if the 'quantity' field is less than or equal to 20
lessThanOrEqual("quantity", constant(20))
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Expression expression

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

lessThanOrEqual

public static final @NonNull BooleanExpression lessThanOrEqual(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is less than or equal to another value.

// Check if the 'score' field is less than or equal to 70
lessThanOrEqual("score", 70)
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Object value

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

lessThanOrEqual

public static final @NonNull BooleanExpression lessThanOrEqual(@NonNull Expression left, @NonNull Object right)

Creates an expression that checks if an expression is less than or equal to a value.

// Check if the 'score' field is less than or equal to 70
lessThanOrEqual(field("score"), 70)
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Object right

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

lessThanOrEqual

public static final @NonNull BooleanExpression lessThanOrEqual(@NonNull Expression left, @NonNull Expression right)

Creates an expression that checks if the first expression is less than or equal to the second expression.

// Check if the 'quantity' field is less than or equal to 20
lessThanOrEqual(field("quantity"), constant(20))
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Expression right

The second expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

like

public static final @NonNull BooleanExpression like(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that performs a case-sensitive wildcard string comparison against a field.

// Check if the 'title' field contains the string "guide"
like("title", "%guide%")
Parameters
@NonNull String fieldName

The name of the field containing the string.

@NonNull Expression pattern

The pattern to search for. You can use "%" as a wildcard character.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the like comparison.

like

public static final @NonNull BooleanExpression like(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that performs a case-sensitive wildcard string comparison against a field.

// Check if the 'title' field contains the string "guide"
like("title", "%guide%")
Parameters
@NonNull String fieldName

The name of the field containing the string.

@NonNull String pattern

The pattern to search for. You can use "%" as a wildcard character.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the like comparison.

like

public static final @NonNull BooleanExpression like(@NonNull Expression stringExpression, @NonNull Expression pattern)

Creates an expression that performs a case-sensitive wildcard string comparison.

// Check if the 'title' field contains the string "guide"
like(field("title"), "%guide%")
Parameters
@NonNull Expression stringExpression

The expression representing the string to perform the comparison on.

@NonNull Expression pattern

The pattern to search for. You can use "%" as a wildcard character.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the like operation.

like

public static final @NonNull BooleanExpression like(@NonNull Expression stringExpression, @NonNull String pattern)

Creates an expression that performs a case-sensitive wildcard string comparison.

// Check if the 'title' field contains the string "guide"
like(field("title"), "%guide%")
Parameters
@NonNull Expression stringExpression

The expression representing the string to perform the comparison on.

@NonNull String pattern

The pattern to search for. You can use "%" as a wildcard character.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the like operation.

ln

public static final @NonNull Expression ln(@NonNull Expression numericExpr)

Creates an expression that returns the natural logarithm (base e) of numericExpr.

// Compute the natural logarithm of the 'value' field.
ln(field("value"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the natural logarithm.

ln

public static final @NonNull Expression ln(@NonNull String numericField)

Creates an expression that returns the natural logarithm (base e) of numericField.

// Compute the natural logarithm of the 'value' field.
ln("value")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the natural logarithm.

log

public static final @NonNull Expression log(@NonNull Expression numericExpr, @NonNull Expression base)

Creates an expression that returns the logarithm of numericExpr with a given base.

// Compute the logarithm of the 'value' field with the base in the 'base' field.
log(field("value"), field("base"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

@NonNull Expression base

The base of the logarithm.

Returns
@NonNull Expression

A new Expression representing a numeric result from the logarithm of numericExpr with a given base.

log

public static final @NonNull Expression log(@NonNull Expression numericExpr, @NonNull Number base)

Creates an expression that returns the logarithm of numericExpr with a given base.

// Compute the logarithm of the 'value' field with base 10.
log(field("value"), 10)
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

@NonNull Number base

The base of the logarithm.

Returns
@NonNull Expression

A new Expression representing a numeric result from the logarithm of numericExpr with a given base.

log

public static final @NonNull Expression log(@NonNull String numericField, @NonNull Expression base)

Creates an expression that returns the logarithm of numericField with a given base.

// Compute the logarithm of the 'value' field with the base in the 'base' field.
log("value", field("base"))
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

@NonNull Expression base

The base of the logarithm.

Returns
@NonNull Expression

A new Expression representing a numeric result from the logarithm of numericField with a given base.

log

public static final @NonNull Expression log(@NonNull String numericField, @NonNull Number base)

Creates an expression that returns the logarithm of numericField with a given base.

// Compute the logarithm of the 'value' field with base 10.
log("value", 10)
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

@NonNull Number base

The base of the logarithm.

Returns
@NonNull Expression

A new Expression representing a numeric result from the logarithm of numericField with a given base.

log10

public static final @NonNull Expression log10(@NonNull Expression numericExpr)

Creates an expression that returns the base 10 logarithm of numericExpr.

// Compute the base 10 logarithm of the 'value' field.
log10(field("value"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the base 10 logarithm.

log10

public static final @NonNull Expression log10(@NonNull String numericField)

Creates an expression that returns the base 10 logarithm of numericField.

// Compute the base 10 logarithm of the 'value' field.
log10("value")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the base 10 logarithm.

logicalMaximum

public static final @NonNull Expression logicalMaximum(@NonNull Expression expr, @NonNull Object others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

// Returns the larger value between the 'timestamp' field and the current timestamp.
logicalMaximum(field("timestamp"), currentTimestamp())
Parameters
@NonNull Expression expr

The first operand expression.

@NonNull Object others

Optional additional expressions or literals.

Returns
@NonNull Expression

A new Expression representing the logical maximum operation.

logicalMaximum

public static final @NonNull Expression logicalMaximum(@NonNull String fieldName, @NonNull Object others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

// Returns the larger value between the 'timestamp' field and the current timestamp.
logicalMaximum("timestamp", currentTimestamp())
Parameters
@NonNull String fieldName

The first operand field name.

@NonNull Object others

Optional additional expressions or literals.

Returns
@NonNull Expression

A new Expression representing the logical maximum operation.

logicalMinimum

public static final @NonNull Expression logicalMinimum(@NonNull Expression expr, @NonNull Object others)

Creates an expression that returns the smallest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

// Returns the smaller value between the 'timestamp' field and the current timestamp.
logicalMinimum(field("timestamp"), currentTimestamp())
Parameters
@NonNull Expression expr

The first operand expression.

@NonNull Object others

Optional additional expressions or literals.

Returns
@NonNull Expression

A new Expression representing the logical minimum operation.

logicalMinimum

public static final @NonNull Expression logicalMinimum(@NonNull String fieldName, @NonNull Object others)

Creates an expression that returns the smallest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

// Returns the smaller value between the 'timestamp' field and the current timestamp.
logicalMinimum("timestamp", currentTimestamp())
Parameters
@NonNull String fieldName

The first operand field name.

@NonNull Object others

Optional additional expressions or literals.

Returns
@NonNull Expression

A new Expression representing the logical minimum operation.

map

public static final @NonNull Expression map(@NonNull Map<@NonNull String, @NonNull Object> elements)

Creates an expression that creates a Firestore map value from an input object.

// Create a map with a constant key and a field value
map
(mapOf("name" to field("productName"), "quantity" to 1))
Parameters
@NonNull Map<@NonNull String, @NonNull Object> elements

The input map to evaluate in the expression.

Returns
@NonNull Expression

A new Expression representing the map function.

mapGet

public static final @NonNull Expression mapGet(@NonNull String fieldName, @NonNull String key)

Accesses a value from a map (object) field using the provided key.

// Get the 'city' value from the 'address' map field
mapGet("address", "city")
Parameters
@NonNull String fieldName

The field name of the map field.

@NonNull String key

The key to access in the map.

Returns
@NonNull Expression

A new Expression representing the value associated with the given key in the map.

mapGet

public static final @NonNull Expression mapGet(@NonNull String fieldName, @NonNull Expression keyExpression)

Accesses a value from a map (object) field using the provided keyExpression.

// Get the value from the 'address' map field, using the key from the 'keyField' field
mapGet("address", field("keyField"))
Parameters
@NonNull String fieldName

The field name of the map field.

@NonNull Expression keyExpression

The key to access in the map.

Returns
@NonNull Expression

A new Expression representing the value associated with the given key in the map.

mapGet

public static final @NonNull Expression mapGet(@NonNull Expression mapExpression, @NonNull String key)

Accesses a value from a map (object) field using the provided key.

// Get the 'city' value from the 'address' map field
mapGet(field("address"), "city")
Parameters
@NonNull Expression mapExpression

The expression representing the map.

@NonNull String key

The key to access in the map.

Returns
@NonNull Expression

A new Expression representing the value associated with the given key in the map.

mapGet

public static final @NonNull Expression mapGet(
    @NonNull Expression mapExpression,
    @NonNull Expression keyExpression
)

Accesses a value from a map (object) field using the provided keyExpression.

// Get the value from the 'address' map field, using the key from the 'keyField' field
mapGet(field("address"), field("keyField"))
Parameters
@NonNull Expression mapExpression

The expression representing the map.

@NonNull Expression keyExpression

The key to access in the map.

Returns
@NonNull Expression

A new Expression representing the value associated with the given key in the map.

mapMerge

public static final @NonNull Expression mapMerge(
    @NonNull Expression firstMap,
    @NonNull Expression secondMap,
    @NonNull Expression otherMaps
)

Creates an expression that merges multiple maps into a single map. If multiple maps have the same key, the later value is used.

// Merges the map in the settings field with, a map literal, and a map in
// that is conditionally returned by another expression
mapMerge(
field("settings"),
map(mapOf("enabled" to true)),
conditional(
field("isAdmin").equal(true),
map(mapOf("admin" to true)),
map(emptyMap<String, Any>())
)
)
Parameters
@NonNull Expression firstMap

First map expression that will be merged.

@NonNull Expression secondMap

Second map expression that will be merged.

@NonNull Expression otherMaps

Additional maps to merge.

Returns
@NonNull Expression

A new Expression representing the mapMerge operation.

mapMerge

public static final @NonNull Expression mapMerge(
    @NonNull String firstMapFieldName,
    @NonNull Expression secondMap,
    @NonNull Expression otherMaps
)

Creates an expression that merges multiple maps into a single map. If multiple maps have the same key, the later value is used.

// Merges the map in the settings field with, a map literal, and a map in
// that is conditionally returned by another expression
mapMerge(
"settings",
map(mapOf("enabled" to true)),
conditional(
field("isAdmin").equal(true),
map(mapOf("admin" to true)),
map(emptyMap<String, Any>())
)
)
Parameters
@NonNull String firstMapFieldName

First map field name that will be merged.

@NonNull Expression secondMap

Second map expression that will be merged.

@NonNull Expression otherMaps

Additional maps to merge.

Returns
@NonNull Expression

A new Expression representing the mapMerge operation.

mapRemove

public static final @NonNull Expression mapRemove(@NonNull Expression mapExpr, @NonNull Expression key)

Creates an expression that removes a key from the map produced by evaluating an expression.

// Removes the key 'baz' from the input map.
mapRemove(map(mapOf("foo" to "bar", "baz" to true)), constant("baz"))
Parameters
@NonNull Expression mapExpr

An expression that evaluates to a map.

@NonNull Expression key

The name of the key to remove from the input map.

Returns
@NonNull Expression

A new Expression that evaluates to a modified map.

mapRemove

public static final @NonNull Expression mapRemove(@NonNull Expression mapExpr, @NonNull String key)

Creates an expression that removes a key from the map produced by evaluating an expression.

// Removes the key 'baz' from the input map.
mapRemove(map(mapOf("foo" to "bar", "baz" to true)), "baz")
Parameters
@NonNull Expression mapExpr

An expression that evaluates to a map.

@NonNull String key

The name of the key to remove from the input map.

Returns
@NonNull Expression

A new Expression that evaluates to a modified map.

mapRemove

public static final @NonNull Expression mapRemove(@NonNull String mapField, @NonNull Expression key)

Creates an expression that removes a key from the map produced by evaluating an expression.

// Removes the key 'city' field from the map in the address field of the input document.
mapRemove("address", constant("city"))
Parameters
@NonNull String mapField

The name of a field containing a map value.

@NonNull Expression key

The name of the key to remove from the input map.

Returns
@NonNull Expression

A new Expression that evaluates to a modified map.

mapRemove

public static final @NonNull Expression mapRemove(@NonNull String mapField, @NonNull String key)

Creates an expression that removes a key from the map produced by evaluating an expression.

// Removes the key 'city' field from the map in the address field of the input document.
mapRemove("address", "city")
Parameters
@NonNull String mapField

The name of a field containing a map value.

@NonNull String key

The name of the key to remove from the input map.

Returns
@NonNull Expression

A new Expression that evaluates to a modified map.

mod

public static final @NonNull Expression mod(@NonNull Expression dividend, @NonNull Expression divisor)

Creates an expression that calculates the modulo (remainder) of dividing two numeric expressions.

// Calculate the remainder of dividing the 'value' field by the 'divisor' field
mod(field("value"), field("divisor"))
Parameters
@NonNull Expression dividend

The numeric expression to be divided.

@NonNull Expression divisor

The numeric expression to divide by.

Returns
@NonNull Expression

A new Expression representing the modulo operation.

mod

public static final @NonNull Expression mod(@NonNull Expression dividend, @NonNull Number divisor)

Creates an expression that calculates the modulo (remainder) of dividing a numeric expression by a constant.

// Calculate the remainder of dividing the 'value' field by 3.
mod(field("value"), 3)
Parameters
@NonNull Expression dividend

The numeric expression to be divided.

@NonNull Number divisor

The constant to divide by.

Returns
@NonNull Expression

A new Expression representing the modulo operation.

mod

public static final @NonNull Expression mod(@NonNull String dividendFieldName, @NonNull Expression divisor)

Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a constant.

// Calculate the remainder of dividing the 'value' field by the 'divisor' field.
mod("value", field("divisor"))
Parameters
@NonNull String dividendFieldName

The numeric field name to be divided.

@NonNull Expression divisor

The numeric expression to divide by.

Returns
@NonNull Expression

A new Expression representing the modulo operation.

mod

public static final @NonNull Expression mod(@NonNull String dividendFieldName, @NonNull Number divisor)

Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a constant.

// Calculate the remainder of dividing the 'value' field by 3.
mod("value", 3)
Parameters
@NonNull String dividendFieldName

The numeric field name to be divided.

@NonNull Number divisor

The constant to divide by.

Returns
@NonNull Expression

A new Expression representing the modulo operation.

multiply

public static final @NonNull Expression multiply(@NonNull Expression first, @NonNull Expression second)

Creates an expression that multiplies numeric expressions.

// Multiply the 'quantity' field by the 'price' field
multiply(field("quantity"), field("price"))
Parameters
@NonNull Expression first

Numeric expression to multiply.

@NonNull Expression second

Numeric expression to multiply.

Returns
@NonNull Expression

A new Expression representing the multiplication operation.

multiply

public static final @NonNull Expression multiply(@NonNull Expression first, @NonNull Number second)

Creates an expression that multiplies numeric expressions with a constant.

// Multiply the 'quantity' field by 1.1.
multiply(field("quantity"), 1.1)
Parameters
@NonNull Expression first

Numeric expression to multiply.

@NonNull Number second

Constant to multiply.

Returns
@NonNull Expression

A new Expression representing the multiplication operation.

multiply

public static final @NonNull Expression multiply(@NonNull String numericFieldName, @NonNull Expression second)

Creates an expression that multiplies a numeric field with a numeric expression.

// Multiply the 'quantity' field by the 'price' field.
multiply("quantity", field("price"))
Parameters
@NonNull String numericFieldName

Numeric field to multiply.

@NonNull Expression second

Numeric expression to multiply.

Returns
@NonNull Expression

A new Expression representing the multiplication operation.

multiply

public static final @NonNull Expression multiply(@NonNull String numericFieldName, @NonNull Number second)

Creates an expression that multiplies a numeric field with a constant.

// Multiply the 'quantity' field by 1.1.
multiply("quantity", 1.1)
Parameters
@NonNull String numericFieldName

Numeric field to multiply.

@NonNull Number second

Constant to multiply.

Returns
@NonNull Expression

A new Expression representing the multiplication operation.

not

public static final @NonNull BooleanExpression not(@NonNull BooleanExpression condition)

Creates an expression that negates a boolean expression.

// Check if 'is_admin' is not true
not(field("is_admin"))
Parameters
@NonNull BooleanExpression condition

The boolean expression to negate.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the not operation.

notEqual

public static final @NonNull BooleanExpression notEqual(@NonNull String fieldName, @NonNull Expression expression)

Creates an expression that checks if a field's value is not equal to an expression.

// Check if the 'status' field is not equal to the value of the 'otherStatus' field
notEqual("status", field("otherStatus"))
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Expression expression

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqual

public static final @NonNull BooleanExpression notEqual(@NonNull String fieldName, @NonNull Object value)

Creates an expression that checks if a field's value is not equal to another value.

// Check if the 'status' field is not equal to "completed"
notEqual("status", "completed")

// Check if the 'country' field is not equal to "USA"
notEqual("country", "USA")
Parameters
@NonNull String fieldName

The field name to compare.

@NonNull Object value

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqual

public static final @NonNull BooleanExpression notEqual(@NonNull Expression left, @NonNull Object right)

Creates an expression that checks if an expression is not equal to a value.

// Check if the 'status' field is not equal to "completed"
notEqual(field("status"), "completed")
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Object right

The value to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqual

public static final @NonNull BooleanExpression notEqual(@NonNull Expression left, @NonNull Expression right)

Creates an expression that checks if two expressions are not equal.

// Check if the 'status' field is not equal to the value of the 'otherStatus' field
notEqual(field("status"), field("otherStatus"))
Parameters
@NonNull Expression left

The first expression to compare.

@NonNull Expression right

The second expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqualAny

public static final @NonNull BooleanExpression notEqualAny(
    @NonNull Expression expression,
    @NonNull Expression arrayExpression
)

Creates an expression that checks if an expression, when evaluated, is not equal to all the elements of arrayExpression.

// Check if the 'status' field is not in the 'inactiveStatuses' array field.
notEqualAny(field("status"), field("inactiveStatuses"))
Parameters
@NonNull Expression expression

The expression whose results to compare.

@NonNull Expression arrayExpression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

notEqualAny

public static final @NonNull BooleanExpression notEqualAny(
    @NonNull Expression expression,
    @NonNull List<@NonNull Object> values
)

Creates an expression that checks if an expression, when evaluated, is not equal to all the provided values.

// Check if the 'status' field is neither "pending" nor the value of the 'rejectedStatus' field.
notEqualAny(field("status"), listOf("pending", field("rejectedStatus")))
Parameters
@NonNull Expression expression

The expression whose results to compare.

@NonNull List<@NonNull Object> values

The values to check against.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

notEqualAny

public static final @NonNull BooleanExpression notEqualAny(@NonNull String fieldName, @NonNull Expression arrayExpression)

Creates an expression that checks if a field's value is not equal to all of the elements of arrayExpression.

// Check if the 'status' field is not in the 'inactiveStatuses' array field.
notEqualAny("status", field("inactiveStatuses"))
Parameters
@NonNull String fieldName

The field to compare.

@NonNull Expression arrayExpression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

notEqualAny

public static final @NonNull BooleanExpression notEqualAny(@NonNull String fieldName, @NonNull List<@NonNull Object> values)

Creates an expression that checks if a field's value is not equal to all of the provided values.

// Check if the 'status' field is not "archived" or "deleted".
notEqualAny("status", listOf("archived", "deleted"))
Parameters
@NonNull String fieldName

The field to compare.

@NonNull List<@NonNull Object> values

The values to check against.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

nullValue

public static final @NonNull Expression nullValue()

Constant for a null value.

// Create a null constant
nullValue
()
Returns
@NonNull Expression

A Expression constant instance.

or

public static final @NonNull BooleanExpression or(
    @NonNull BooleanExpression condition,
    @NonNull BooleanExpression conditions
)

Creates an expression that performs a logical 'OR' operation.

// Check if 'status' is "new" or "open"
or(field("status").equal("new"), field("status").equal("open"))
Parameters
@NonNull BooleanExpression condition

The first BooleanExpression.

@NonNull BooleanExpression conditions

Additional BooleanExpressions.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the logical 'OR' operation.

pow

public static final @NonNull Expression pow(@NonNull Expression numericExpr, @NonNull Expression exponent)

Creates an expression that returns the numericExpr raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

// Raise the value of the 'base' field to the power of the 'exponent' field.
pow(field("base"), field("exponent"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

@NonNull Expression exponent

The numeric power to raise the numericExpr.

Returns
@NonNull Expression

A new Expression representing a numeric result from raising numericExpr to the power of exponent.

pow

public static final @NonNull Expression pow(@NonNull Expression numericExpr, @NonNull Number exponent)

Creates an expression that returns the numericExpr raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

// Raise the value of the 'base' field to the power of 2.
pow(field("base"), 2)
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

@NonNull Number exponent

The numeric power to raise the numericExpr.

Returns
@NonNull Expression

A new Expression representing a numeric result from raising numericExpr to the power of exponent.

pow

public static final @NonNull Expression pow(@NonNull String numericField, @NonNull Expression exponent)

Creates an expression that returns the numericField raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

// Raise the value of the 'base' field to the power of the 'exponent' field.
pow("base", field("exponent"))
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

@NonNull Expression exponent

The numeric power to raise the numericField.

Returns
@NonNull Expression

A new Expression representing a numeric result from raising numericField to the power of exponent.

pow

public static final @NonNull Expression pow(@NonNull String numericField, @NonNull Number exponent)

Creates an expression that returns the numericField raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

// Raise the value of the 'base' field to the power of 2.
pow("base", 2)
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

@NonNull Number exponent

The numeric power to raise the numericField.

Returns
@NonNull Expression

A new Expression representing a numeric result from raising numericField to the power of exponent.

rawFunction

public static final @NonNull Expression rawFunction(@NonNull String name, @NonNull Expression expr)

Creates a 'raw' function expression. This is useful if the expression is available in the backend, but not yet in the current version of the SDK yet.

// Create a generic function call
rawFunction
("my_function", field("arg1"), constant(42))
Parameters
@NonNull String name

The name of the raw function.

@NonNull Expression expr

The expressions to be passed as arguments to the function.

Returns
@NonNull Expression

A new Expression representing the raw function.

regexContains

public static final @NonNull BooleanExpression regexContains(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that checks if a string field contains a specified regular expression as a substring.

// Check if the 'description' field contains the regex from the 'pattern' field.
regexContains("description", field("pattern"))
Parameters
@NonNull String fieldName

The name of the field containing the string.

@NonNull Expression pattern

The regular expression to use for the search.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexContains

public static final @NonNull BooleanExpression regexContains(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that checks if a string field contains a specified regular expression as a substring.

// Check if the 'description' field contains "example" (case-insensitive)
regexContains("description", "(?i)example")
Parameters
@NonNull String fieldName

The name of the field containing the string.

@NonNull String pattern

The regular expression to use for the search.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexContains

public static final @NonNull BooleanExpression regexContains(
    @NonNull Expression stringExpression,
    @NonNull Expression pattern
)

Creates an expression that checks if a string expression contains a specified regular expression as a substring.

// Check if the 'description' field contains "example" (case-insensitive)
regexContains(field("description"), "(?i)example")
Parameters
@NonNull Expression stringExpression

The expression representing the string to perform the comparison on.

@NonNull Expression pattern

The regular expression to use for the search.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexContains

public static final @NonNull BooleanExpression regexContains(
    @NonNull Expression stringExpression,
    @NonNull String pattern
)

Creates an expression that checks if a string expression contains a specified regular expression as a substring.

// Check if the 'description' field contains "example" (case-insensitive)
regexContains(field("description"), "(?i)example")
Parameters
@NonNull Expression stringExpression

The expression representing the string to perform the comparison on.

@NonNull String pattern

The regular expression to use for the search.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexMatch

public static final @NonNull BooleanExpression regexMatch(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that checks if a string field matches a specified regular expression.

// Check if the 'email' field matches the regex from the 'pattern' field.
regexMatch("email", field("pattern"))
Parameters
@NonNull String fieldName

The name of the field containing the string.

@NonNull Expression pattern

The regular expression to use for the match.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

regexMatch

public static final @NonNull BooleanExpression regexMatch(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that checks if a string field matches a specified regular expression.

// Check if the 'email' field matches a valid email pattern
regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")
Parameters
@NonNull String fieldName

The name of the field containing the string.

@NonNull String pattern

The regular expression to use for the match.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

regexMatch

public static final @NonNull BooleanExpression regexMatch(
    @NonNull Expression stringExpression,
    @NonNull Expression pattern
)

Creates an expression that checks if a string field matches a specified regular expression.

// Check if the 'email' field matches a valid email pattern
regexMatch(field("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")
Parameters
@NonNull Expression stringExpression

The expression representing the string to match against.

@NonNull Expression pattern

The regular expression to use for the match.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

regexMatch

public static final @NonNull BooleanExpression regexMatch(@NonNull Expression stringExpression, @NonNull String pattern)

Creates an expression that checks if a string field matches a specified regular expression.

// Check if the 'email' field matches a valid email pattern
regexMatch(field("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}")
Parameters
@NonNull Expression stringExpression

The expression representing the string to match against.

@NonNull String pattern

The regular expression to use for the match.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

reverse

public static final @NonNull Expression reverse(@NonNull String fieldName)

Creates an expression that reverses a string value from the specified field.

// Reverse the value of the 'myString' field.
reverse("myString")
Parameters
@NonNull String fieldName

The name of the field that contains the string to reverse.

Returns
@NonNull Expression

A new Expression representing the reversed string.

reverse

public static final @NonNull Expression reverse(@NonNull Expression stringExpression)

Creates an expression that reverses a string.

// Reverse the value of the 'myString' field.
reverse(field("myString"))
Parameters
@NonNull Expression stringExpression

An expression evaluating to a string value, which will be reversed.

Returns
@NonNull Expression

A new Expression representing the reversed string.

round

public static final @NonNull Expression round(@NonNull Expression numericExpr)

Creates an expression that rounds numericExpr to nearest integer.

// Round the value of the 'price' field.
round(field("price"))

Rounds away from zero in halfway cases.

Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing an integer result from the round operation.

round

public static final @NonNull Expression round(@NonNull String numericField)

Creates an expression that rounds numericField to nearest integer.

// Round the value of the 'price' field.
round("price")

Rounds away from zero in halfway cases.

Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing an integer result from the round operation.

roundToPrecision

public static final @NonNull Expression roundToPrecision(
    @NonNull Expression numericExpr,
    @NonNull Expression decimalPlace
)

Creates an expression that rounds off numericExpr to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

// Round the value of the 'price' field to the number of decimal places specified in the
// 'precision' field.
roundToPrecision(field("price"), field("precision"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

@NonNull Expression decimalPlace

The number of decimal places to round.

Returns
@NonNull Expression

A new Expression representing the round operation.

roundToPrecision

public static final @NonNull Expression roundToPrecision(@NonNull Expression numericExpr, int decimalPlace)

Creates an expression that rounds off numericExpr to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

// Round the value of the 'price' field to 2 decimal places.
roundToPrecision(field("price"), 2)
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

int decimalPlace

The number of decimal places to round.

Returns
@NonNull Expression

A new Expression representing the round operation.

roundToPrecision

public static final @NonNull Expression roundToPrecision(
    @NonNull String numericField,
    @NonNull Expression decimalPlace
)

Creates an expression that rounds off numericField to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

// Round the value of the 'price' field to the number of decimal places specified in the
// 'precision' field.
roundToPrecision("price", field("precision"))
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

@NonNull Expression decimalPlace

The number of decimal places to round.

Returns
@NonNull Expression

A new Expression representing the round operation.

roundToPrecision

public static final @NonNull Expression roundToPrecision(@NonNull String numericField, int decimalPlace)

Creates an expression that rounds off numericField to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

// Round the value of the 'price' field to 2 decimal places.
roundToPrecision("price", 2)
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

int decimalPlace

The number of decimal places to round.

Returns
@NonNull Expression

A new Expression representing the round operation.

split

public static final @NonNull Expression split(@NonNull String fieldName, @NonNull Blob delimiter)

Creates an expression that splits a blob field by a blob delimiter.

// Split the 'data' field by a delimiter
split("data", Blob.fromBytes(byteArrayOf(0x0a)))
Parameters
@NonNull String fieldName

The name of the field containing the blob to be split.

@NonNull Blob delimiter

The blob delimiter to split by.

Returns
@NonNull Expression

A new Expression that evaluates to an array of segments.

split

public static final @NonNull Expression split(@NonNull String fieldName, @NonNull Expression delimiter)

Creates an expression that splits a string or blob field by a delimiter.

// Split the 'tags' field by the value of the 'delimiter' field
split("tags", field("delimiter"))
Parameters
@NonNull String fieldName

The name of the field containing the string or blob to be split.

@NonNull Expression delimiter

The delimiter to split by.

Returns
@NonNull Expression

A new Expression that evaluates to an array of segments.

split

public static final @NonNull Expression split(@NonNull String fieldName, @NonNull String delimiter)

Creates an expression that splits a string or blob field by a string delimiter.

// Split the 'tags' field by a comma
split("tags", ",")
Parameters
@NonNull String fieldName

The name of the field containing the string or blob to be split.

@NonNull String delimiter

The string delimiter to split by.

Returns
@NonNull Expression

A new Expression that evaluates to an array of segments.

split

public static final @NonNull Expression split(@NonNull Expression value, @NonNull Blob delimiter)

Creates an expression that splits a blob by a blob delimiter.

// Split the 'data' field by a delimiter
split(field("data"), Blob.fromBytes(byteArrayOf(0x0a)))
Parameters
@NonNull Expression value

The expression evaluating to a blob to be split.

@NonNull Blob delimiter

The blob delimiter to split by.

Returns
@NonNull Expression

A new Expression that evaluates to an array of segments.

split

public static final @NonNull Expression split(@NonNull Expression value, @NonNull Expression delimiter)

Creates an expression that splits a string or blob by a delimiter.

// Split the 'tags' field by a comma
split(field("tags"), field("delimiter"))
Parameters
@NonNull Expression value

The expression evaluating to a string or blob to be split.

@NonNull Expression delimiter

The delimiter to split by. Must be of the same type as value.

Returns
@NonNull Expression

A new Expression that evaluates to an array of segments.

split

public static final @NonNull Expression split(@NonNull Expression value, @NonNull String delimiter)

Creates an expression that splits a string or blob by a string delimiter.

// Split the 'tags' field by a comma
split(field("tags"), ",")
Parameters
@NonNull Expression value

The expression evaluating to a string or blob to be split.

@NonNull String delimiter

The string delimiter to split by.

Returns
@NonNull Expression

A new Expression that evaluates to an array of segments.

sqrt

public static final @NonNull Expression sqrt(@NonNull Expression numericExpr)

Creates an expression that returns the square root of numericExpr.

// Compute the square root of the 'value' field.
sqrt(field("value"))
Parameters
@NonNull Expression numericExpr

An expression that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the square root operation.

sqrt

public static final @NonNull Expression sqrt(@NonNull String numericField)

Creates an expression that returns the square root of numericField.

// Compute the square root of the 'value' field.
sqrt("value")
Parameters
@NonNull String numericField

Name of field that returns number when evaluated.

Returns
@NonNull Expression

A new Expression representing the numeric result of the square root operation.

startsWith

public static final @NonNull BooleanExpression startsWith(@NonNull String fieldName, @NonNull Expression prefix)

Creates an expression that checks if a string expression starts with a given prefix.

// Check if the 'fullName' field starts with the value of the 'firstName' field
startsWith("fullName", field("firstName"))
Parameters
@NonNull String fieldName

The name of field that contains a string to check.

@NonNull Expression prefix

The prefix string expression to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

startsWith

public static final @NonNull BooleanExpression startsWith(@NonNull String fieldName, @NonNull String prefix)

Creates an expression that checks if a string expression starts with a given prefix.

// Check if the 'name' field starts with "Mr."
startsWith("name", "Mr.")
Parameters
@NonNull String fieldName

The name of field that contains a string to check.

@NonNull String prefix

The prefix string to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

startsWith

public static final @NonNull BooleanExpression startsWith(@NonNull Expression stringExpr, @NonNull Expression prefix)
// Check if the 'fullName' field starts with the value of the 'firstName' field
startsWith(field("fullName"), field("firstName"))
Parameters
@NonNull Expression stringExpr

The expression to check.

@NonNull Expression prefix

The prefix string expression to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

startsWith

public static final @NonNull BooleanExpression startsWith(@NonNull Expression stringExpr, @NonNull String prefix)

Creates an expression that checks if a string expression starts with a given prefix.

// Check if the 'name' field starts with "Mr."
startsWith(field("name"), "Mr.")
Parameters
@NonNull Expression stringExpr

The expression to check.

@NonNull String prefix

The prefix string to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

stringConcat

public static final @NonNull Expression stringConcat(@NonNull String fieldName, @NonNull Object otherStrings)

Creates an expression that concatenates string expressions together.

// Combine the 'firstName', " ", and 'lastName' fields into a single string
stringConcat("firstName", " ", "lastName")
Parameters
@NonNull String fieldName

The field name containing the initial string value.

@NonNull Object otherStrings

Optional additional string expressions or string constants to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenated string.

stringConcat

public static final @NonNull Expression stringConcat(@NonNull String fieldName, @NonNull Expression otherStrings)

Creates an expression that concatenates string expressions together.

// Combine the 'firstName', " ", and 'lastName' fields into a single string
stringConcat
("firstName", constant(" "), field("lastName"))
Parameters
@NonNull String fieldName

The field name containing the initial string value.

@NonNull Expression otherStrings

Optional additional string expressions to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenated string.

stringConcat

public static final @NonNull Expression stringConcat(@NonNull Expression firstString, @NonNull Object otherStrings)

Creates an expression that concatenates string expressions together.

// Combine the 'firstName', " ", and 'lastName' fields into a single string
stringConcat(field("firstName"), " ", field("lastName"))
Parameters
@NonNull Expression firstString

The expression representing the initial string value.

@NonNull Object otherStrings

Optional additional string expressions or string constants to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenated string.

stringConcat

public static final @NonNull Expression stringConcat(
    @NonNull Expression firstString,
    @NonNull Expression otherStrings
)

Creates an expression that concatenates string expressions together.

// Combine the 'firstName', " ", and 'lastName' fields into a single string
stringConcat
(field("firstName"), constant(" "), field("lastName"))
Parameters
@NonNull Expression firstString

The expression representing the initial string value.

@NonNull Expression otherStrings

Optional additional string expressions to concatenate.

Returns
@NonNull Expression

A new Expression representing the concatenated string.

stringContains

public static final @NonNull BooleanExpression stringContains(@NonNull String fieldName, @NonNull Expression substring)

Creates an expression that checks if a string field contains a specified substring.

// Check if the 'description' field contains the value of the 'keyword' field.
stringContains("description", field("keyword"))
Parameters
@NonNull String fieldName

The name of the field to perform the comparison on.

@NonNull Expression substring

The expression representing the substring to search for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains comparison.

stringContains

public static final @NonNull BooleanExpression stringContains(@NonNull String fieldName, @NonNull String substring)

Creates an expression that checks if a string field contains a specified substring.

// Check if the 'description' field contains "example".
stringContains("description", "example")
Parameters
@NonNull String fieldName

The name of the field to perform the comparison on.

@NonNull String substring

The substring to search for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains comparison.

stringContains

public static final @NonNull BooleanExpression stringContains(
    @NonNull Expression stringExpression,
    @NonNull Expression substring
)

Creates an expression that checks if a string expression contains a specified substring.

// Check if the 'description' field contains the value of the 'keyword' field.
stringContains(field("description"), field("keyword"))
Parameters
@NonNull Expression stringExpression

The expression representing the string to perform the comparison on.

@NonNull Expression substring

The expression representing the substring to search for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains comparison.

stringContains

public static final @NonNull BooleanExpression stringContains(
    @NonNull Expression stringExpression,
    @NonNull String substring
)

Creates an expression that checks if a string expression contains a specified substring.

// Check if the 'description' field contains "example".
stringContains(field("description"), "example")
Parameters
@NonNull Expression stringExpression

The expression representing the string to perform the comparison on.

@NonNull String substring

The substring to search for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the contains comparison.

stringReverse

public static final @NonNull Expression stringReverse(@NonNull String fieldName)

Reverses the given string field.

// Reverse the value of the 'myString' field.
stringReverse("myString")
Parameters
@NonNull String fieldName

The name of field that contains the string to reverse.

Returns
@NonNull Expression

A new Expression representing the stringReverse operation.

stringReverse

public static final @NonNull Expression stringReverse(@NonNull Expression str)

Reverses the given string expression.

// Reverse the value of the 'myString' field.
stringReverse(field("myString"))
Parameters
@NonNull Expression str

The string expression to reverse.

Returns
@NonNull Expression

A new Expression representing the stringReverse operation.

substring

public static final @NonNull Expression substring(@NonNull String fieldName, int index, int length)

Creates an expression that returns a substring of the given string.

// Get a substring of the 'message' field starting at index 5 with length 10.
substring("message", 5, 10)
Parameters
@NonNull String fieldName

The name of the field containing the string to get a substring from.

int index

The starting index of the substring.

int length

The length of the substring.

Returns
@NonNull Expression

A new Expression representing the substring.

substring

public static final @NonNull Expression substring(
    @NonNull Expression stringExpression,
    @NonNull Expression index,
    @NonNull Expression length
)

Creates an expression that returns a substring of the given string.

// Get a substring of the 'message' field starting at index 5 with length 10.
substring(field("message"), constant(5), constant(10))
Parameters
@NonNull Expression stringExpression

The expression representing the string to get a substring from.

@NonNull Expression index

The starting index of the substring.

@NonNull Expression length

The length of the substring.

Returns
@NonNull Expression

A new Expression representing the substring.

subtract

public static final @NonNull Expression subtract(@NonNull Expression minuend, @NonNull Expression subtrahend)

Creates an expression that subtracts two expressions.

// Subtract the 'discount' field from the 'price' field
subtract(field("price"), field("discount"))
Parameters
@NonNull Expression minuend

Numeric expression to subtract from.

@NonNull Expression subtrahend

Numeric expression to subtract.

Returns
@NonNull Expression

A new Expression representing the subtract operation.

subtract

public static final @NonNull Expression subtract(@NonNull Expression minuend, @NonNull Number subtrahend)

Creates an expression that subtracts a constant value from a numeric expression.

// Subtract 10 from the 'price' field.
subtract(field("price"), 10)
Parameters
@NonNull Expression minuend

Numeric expression to subtract from.

@NonNull Number subtrahend

Constant to subtract.

Returns
@NonNull Expression

A new Expression representing the subtract operation.

subtract

public static final @NonNull Expression subtract(@NonNull String numericFieldName, @NonNull Expression subtrahend)

Creates an expression that subtracts a numeric expressions from numeric field.

// Subtract the 'discount' field from the 'price' field.
subtract("price", field("discount"))
Parameters
@NonNull String numericFieldName

Numeric field to subtract from.

@NonNull Expression subtrahend

Numeric expression to subtract.

Returns
@NonNull Expression

A new Expression representing the subtract operation.

subtract

public static final @NonNull Expression subtract(@NonNull String numericFieldName, @NonNull Number subtrahend)

Creates an expression that subtracts a constant from numeric field.

// Subtract 10 from the 'price' field.
subtract("price", 10)
Parameters
@NonNull String numericFieldName

Numeric field to subtract from.

@NonNull Number subtrahend

Constant to subtract.

Returns
@NonNull Expression

A new Expression representing the subtract operation.

timestampAdd

public static final @NonNull Expression timestampAdd(
    @NonNull String fieldName,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that adds a specified amount of time to a timestamp.

// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field.
timestampAdd("timestamp", field("unit"), field("amount"))
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

@NonNull Expression unit

The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

@NonNull Expression amount

The expression representing the amount of time to add.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampAdd

public static final @NonNull Expression timestampAdd(@NonNull String fieldName, @NonNull String unit, long amount)

Creates an expression that adds a specified amount of time to a timestamp.

// Add 1 day to the 'timestamp' field.
timestampAdd("timestamp", "day", 1)
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

@NonNull String unit

The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

long amount

The amount of time to add.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampAdd

public static final @NonNull Expression timestampAdd(
    @NonNull Expression timestamp,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that adds a specified amount of time to a timestamp.

// Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field.
timestampAdd(field("timestamp"), field("unit"), field("amount"))
Parameters
@NonNull Expression timestamp

The expression representing the timestamp.

@NonNull Expression unit

The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

@NonNull Expression amount

The expression representing the amount of time to add.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampAdd

public static final @NonNull Expression timestampAdd(
    @NonNull Expression timestamp,
    @NonNull String unit,
    long amount
)

Creates an expression that adds a specified amount of time to a timestamp.

// Add 1 day to the 'timestamp' field.
timestampAdd(field("timestamp"), "day", 1)
Parameters
@NonNull Expression timestamp

The expression representing the timestamp.

@NonNull String unit

The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

long amount

The amount of time to add.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampSubtract

public static final @NonNull Expression timestampSubtract(
    @NonNull String fieldName,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field.
timestampSubtract("timestamp", field("unit"), field("amount"))
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

@NonNull Expression unit

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

@NonNull Expression amount

The amount of time to subtract.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampSubtract

public static final @NonNull Expression timestampSubtract(
    @NonNull String fieldName,
    @NonNull String unit,
    long amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

// Subtract 1 day from the 'timestamp' field.
timestampSubtract("timestamp", "day", 1)
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

@NonNull String unit

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

long amount

The amount of time to subtract.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampSubtract

public static final @NonNull Expression timestampSubtract(
    @NonNull Expression timestamp,
    @NonNull Expression unit,
    @NonNull Expression amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

// Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field.
timestampSubtract(field("timestamp"), field("unit"), field("amount"))
Parameters
@NonNull Expression timestamp

The expression representing the timestamp.

@NonNull Expression unit

The expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

@NonNull Expression amount

The expression representing the amount of time to subtract.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampSubtract

public static final @NonNull Expression timestampSubtract(
    @NonNull Expression timestamp,
    @NonNull String unit,
    long amount
)

Creates an expression that subtracts a specified amount of time to a timestamp.

// Subtract 1 day from the 'timestamp' field.
timestampSubtract(field("timestamp"), "day", 1)
Parameters
@NonNull Expression timestamp

The expression representing the timestamp.

@NonNull String unit

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

long amount

The amount of time to subtract.

Returns
@NonNull Expression

A new Expression representing the resulting timestamp.

timestampToUnixMicros

public static final @NonNull Expression timestampToUnixMicros(@NonNull Expression expr)

Creates an expression that converts a timestamp expression to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

// Convert the 'timestamp' field to microseconds since epoch.
timestampToUnixMicros(field("timestamp"))
Parameters
@NonNull Expression expr

The expression representing the timestamp.

Returns
@NonNull Expression

A new Expression representing the number of microseconds since epoch.

timestampToUnixMicros

public static final @NonNull Expression timestampToUnixMicros(@NonNull String fieldName)

Creates an expression that converts a timestamp field to the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

// Convert the 'timestamp' field to microseconds since epoch.
timestampToUnixMicros("timestamp")
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

Returns
@NonNull Expression

A new Expression representing the number of microseconds since epoch.

timestampToUnixMillis

public static final @NonNull Expression timestampToUnixMillis(@NonNull Expression expr)

Creates an expression that converts a timestamp expression to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

// Convert the 'timestamp' field to milliseconds since epoch.
timestampToUnixMillis(field("timestamp"))
Parameters
@NonNull Expression expr

The expression representing the timestamp.

Returns
@NonNull Expression

A new Expression representing the number of milliseconds since epoch.

timestampToUnixMillis

public static final @NonNull Expression timestampToUnixMillis(@NonNull String fieldName)

Creates an expression that converts a timestamp field to the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC).

// Convert the 'timestamp' field to milliseconds since epoch.
timestampToUnixMillis("timestamp")
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

Returns
@NonNull Expression

A new Expression representing the number of milliseconds since epoch.

timestampToUnixSeconds

public static final @NonNull Expression timestampToUnixSeconds(@NonNull Expression expr)

Creates an expression that converts a timestamp expression to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).

// Convert the 'timestamp' field to seconds since epoch.
timestampToUnixSeconds(field("timestamp"))
Parameters
@NonNull Expression expr

The expression representing the timestamp.

Returns
@NonNull Expression

A new Expression representing the number of seconds since epoch.

timestampToUnixSeconds

public static final @NonNull Expression timestampToUnixSeconds(@NonNull String fieldName)

Creates an expression that converts a timestamp field to the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC).

// Convert the 'timestamp' field to seconds since epoch.
timestampToUnixSeconds("timestamp")
Parameters
@NonNull String fieldName

The name of the field that contains the timestamp.

Returns
@NonNull Expression

A new Expression representing the number of seconds since epoch.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull String fieldName,
    @NonNull Expression granularity
)

Creates an expression that truncates a timestamp to a specified granularity.

// Truncate the 'createdAt' timestamp to the beginning of the day.
timestampTruncate("createdAt", field("granularity"))
Parameters
@NonNull String fieldName

The name of the field containing the timestamp.

@NonNull Expression granularity

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(@NonNull String fieldName, @NonNull String granularity)

Creates an expression that truncates a timestamp to a specified granularity.

// Truncate the 'createdAt' timestamp to the beginning of the day.
timestampTruncate("createdAt", "day")
Parameters
@NonNull String fieldName

The name of the field containing the timestamp.

@NonNull String granularity

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull Expression granularity
)

Creates an expression that truncates a timestamp to a specified granularity.

// Truncate the 'createdAt' timestamp to the beginning of the day.
timestampTruncate(field("createdAt"), field("granularity"))
Parameters
@NonNull Expression timestamp

The timestamp expression.

@NonNull Expression granularity

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull String granularity
)

Creates an expression that truncates a timestamp to a specified granularity.

// Truncate the 'createdAt' timestamp to the beginning of the day.
timestampTruncate(field("createdAt"), "day")
Parameters
@NonNull Expression timestamp

The timestamp expression.

@NonNull String granularity

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull String fieldName,
    @NonNull Expression granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

// Truncate the 'createdAt' timestamp to the beginning of the day in "America/Los_Angeles"
// timezone.
timestampTruncate("createdAt", field("granularity"), "America/Los_Angeles")
Parameters
@NonNull String fieldName

The name of the field containing the timestamp.

@NonNull Expression granularity

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

@NonNull String timezone

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull String fieldName,
    @NonNull String granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

// Truncate the 'createdAt' timestamp to the beginning of the day in "America/Los_Angeles"
// timezone.
timestampTruncate("createdAt", "day", "America/Los_Angeles")
Parameters
@NonNull String fieldName

The name of the field containing the timestamp.

@NonNull String granularity

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

@NonNull String timezone

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull Expression granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

// Truncate the 'createdAt' timestamp to the beginning of the day in "America/Los_Angeles"
// timezone.
timestampTruncate(field("createdAt"), field("granularity"), "America/Los_Angeles")
Parameters
@NonNull Expression timestamp

The timestamp expression.

@NonNull Expression granularity

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

@NonNull String timezone

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

timestampTruncate

public static final @NonNull Expression timestampTruncate(
    @NonNull Expression timestamp,
    @NonNull String granularity,
    @NonNull String timezone
)

Creates an expression that truncates a timestamp to a specified granularity in a given timezone.

// Truncate the 'createdAt' timestamp to the beginning of the day in "America/Los_Angeles"
// timezone.
timestampTruncate(field("createdAt"), "day", "America/Los_Angeles")
Parameters
@NonNull Expression timestamp

The timestamp expression.

@NonNull String granularity

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

@NonNull String timezone

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
@NonNull Expression

A new Expression representing the truncated timestamp.

toLower

public static final @NonNull Expression toLower(@NonNull String fieldName)

Creates an expression that converts a string field to lowercase.

// Convert the 'name' field to lowercase
toLower("name")
Parameters
@NonNull String fieldName

The name of the field containing the string to convert to lowercase.

Returns
@NonNull Expression

A new Expression representing the lowercase string.

toLower

public static final @NonNull Expression toLower(@NonNull Expression stringExpression)

Creates an expression that converts a string expression to lowercase.

// Convert the 'name' field to lowercase
toLower(field("name"))
Parameters
@NonNull Expression stringExpression

The expression representing the string to convert to lowercase.

Returns
@NonNull Expression

A new Expression representing the lowercase string.

toUpper

public static final @NonNull Expression toUpper(@NonNull String fieldName)

Creates an expression that converts a string field to uppercase.

// Convert the 'title' field to uppercase
toUpper("title")
Parameters
@NonNull String fieldName

The name of the field containing the string to convert to uppercase.

Returns
@NonNull Expression

A new Expression representing the uppercase string.

toUpper

public static final @NonNull Expression toUpper(@NonNull Expression stringExpression)

Creates an expression that converts a string expression to uppercase.

// Convert the 'title' field to uppercase
toUpper(field("title"))
Parameters
@NonNull Expression stringExpression

The expression representing the string to convert to uppercase.

Returns
@NonNull Expression

A new Expression representing the uppercase string.

trim

public static final @NonNull Expression trim(@NonNull String fieldName)

Creates an expression that removes leading and trailing whitespace from a string field.

// Trim whitespace from the 'userInput' field
trim("userInput")
Parameters
@NonNull String fieldName

The name of the field containing the string to trim.

Returns
@NonNull Expression

A new Expression representing the trimmed string.

trim

public static final @NonNull Expression trim(@NonNull Expression stringExpression)

Creates an expression that removes leading and trailing whitespace from a string expression.

// Trim whitespace from the 'userInput' field
trim(field("userInput"))
Parameters
@NonNull Expression stringExpression

The expression representing the string to trim.

Returns
@NonNull Expression

A new Expression representing the trimmed string.

trimValue

public static final @NonNull Expression trimValue(@NonNull String fieldName, @NonNull String valueToTrim)

Creates an expression that removes leading and trailing characters from a string field.

// Trim '-', and '_' from the beginning and the end of 'userInput' field
trimValue("userInput", "-_")
Parameters
@NonNull String fieldName

The name of the field containing the string to trim.

@NonNull String valueToTrim

This parameter is treated as a set of characters or bytes that will be matched against the input from both ends.

Returns
@NonNull Expression

A new Expression representing the trimmed string.

trimValue

public static final @NonNull Expression trimValue(
    @NonNull Expression stringExpression,
    @NonNull Expression valueToTrim
)

Creates an expression that removes leading and trailing values from a expression. The accepted values types are string and blob.

// Trim specified characters from the 'userInput' field
trimValue(field("userInput"), field("valueToTrim"))
Parameters
@NonNull Expression stringExpression

The expression representing the string to trim.

@NonNull Expression valueToTrim

The expression evaluated to either a string or a blob. This parameter is treated as a set of characters or bytes that will be matched against the input from both ends.

Returns
@NonNull Expression

A new Expression representing the trimmed string or bytes.

type

public static final @NonNull Expression type(@NonNull Expression expr)

Creates an expression that returns a string indicating the type of the value this expression evaluates to.

// Get the type of the 'value' field.
type(field("value"))
Parameters
@NonNull Expression expr

The expression to get the type of.

Returns
@NonNull Expression

A new Expression representing the type operation.

type

public static final @NonNull Expression type(@NonNull String fieldName)

Creates an expression that returns a string indicating the type of the value this field evaluates to.

// Get the type of the 'field' field.
type("field")
Parameters
@NonNull String fieldName

The name of the field to get the type of.

Returns
@NonNull Expression

A new Expression representing the type operation.

unixMicrosToTimestamp

public static final @NonNull Expression unixMicrosToTimestamp(@NonNull Expression expr)

Creates an expression that interprets an expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

// Interpret the 'microseconds' field as microseconds since epoch.
unixMicrosToTimestamp(field("microseconds"))
Parameters
@NonNull Expression expr

The expression representing the number of microseconds since epoch.

Returns
@NonNull Expression

A new Expression representing the timestamp.

unixMicrosToTimestamp

public static final @NonNull Expression unixMicrosToTimestamp(@NonNull String fieldName)

Creates an expression that interprets a field's value as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

// Interpret the 'microseconds' field as microseconds since epoch.
unixMicrosToTimestamp("microseconds")
Parameters
@NonNull String fieldName

The name of the field containing the number of microseconds since epoch.

Returns
@NonNull Expression

A new Expression representing the timestamp.

unixMillisToTimestamp

public static final @NonNull Expression unixMillisToTimestamp(@NonNull Expression expr)

Creates an expression that interprets an expression as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

// Interpret the 'milliseconds' field as milliseconds since epoch.
unixMillisToTimestamp(field("milliseconds"))
Parameters
@NonNull Expression expr

The expression representing the number of milliseconds since epoch.

Returns
@NonNull Expression

A new Expression representing the timestamp.

unixMillisToTimestamp

public static final @NonNull Expression unixMillisToTimestamp(@NonNull String fieldName)

Creates an expression that interprets a field's value as the number of milliseconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

// Interpret the 'milliseconds' field as milliseconds since epoch.
unixMillisToTimestamp("milliseconds")
Parameters
@NonNull String fieldName

The name of the field containing the number of milliseconds since epoch.

Returns
@NonNull Expression

A new Expression representing the timestamp.

unixSecondsToTimestamp

public static final @NonNull Expression unixSecondsToTimestamp(@NonNull Expression expr)

Creates an expression that interprets an expression as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

// Interpret the 'seconds' field as seconds since epoch.
unixSecondsToTimestamp(field("seconds"))
Parameters
@NonNull Expression expr

The expression representing the number of seconds since epoch.

Returns
@NonNull Expression

A new Expression representing the timestamp.

unixSecondsToTimestamp

public static final @NonNull Expression unixSecondsToTimestamp(@NonNull String fieldName)

Creates an expression that interprets a field's value as the number of seconds since the Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp.

// Interpret the 'seconds' field as seconds since epoch.
unixSecondsToTimestamp("seconds")
Parameters
@NonNull String fieldName

The name of the field containing the number of seconds since epoch.

Returns
@NonNull Expression

A new Expression representing the timestamp.

vector

public static final @NonNull Expression vector(@NonNull double[] vector)

Create a vector constant for a DoubleArray value.

// Create a vector constant from a DoubleArray
vector
(doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@NonNull double[] vector

The DoubleArray value.

Returns
@NonNull Expression

A Expression constant instance.

vector

public static final @NonNull Expression vector(@NonNull VectorValue vector)

Create a vector constant for a VectorValue value.

// Create a vector constant from a VectorValue
vector
(VectorValue(listOf(1.0, 2.0, 3.0)))
Parameters
@NonNull VectorValue vector

The VectorValue value.

Returns
@NonNull Expression

A Expression constant instance.

vectorLength

public static final @NonNull Expression vectorLength(@NonNull String fieldName)

Creates an expression that calculates the length (dimension) of a Firestore Vector.

// Get the vector length (dimension) of the field 'embedding'.
vectorLength("embedding")
Parameters
@NonNull String fieldName

The name of the field containing the Firestore Vector.

Returns
@NonNull Expression

A new Expression representing the length (dimension) of the vector.

vectorLength

public static final @NonNull Expression vectorLength(@NonNull Expression vectorExpression)

Creates an expression that calculates the length (dimension) of a Firestore Vector.

// Get the vector length (dimension) of the field 'embedding'.
vectorLength(field("embedding"))
Parameters
@NonNull Expression vectorExpression

The expression representing the Firestore Vector.

Returns
@NonNull Expression

A new Expression representing the length (dimension) of the vector.

xor

public static final @NonNull BooleanExpression xor(
    @NonNull BooleanExpression condition,
    @NonNull BooleanExpression conditions
)

Creates an expression that performs a logical 'XOR' operation.

// Check if either 'a' is true or 'b' is true, but not both
xor(field("a"), field("b"))
Parameters
@NonNull BooleanExpression condition

The first BooleanExpression.

@NonNull BooleanExpression conditions

Additional BooleanExpressions.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the logical 'XOR' operation.