Expression

@Beta
public abstract class Expression

Known direct subclasses
BooleanExpression

A class that represents a filter condition.

FunctionExpression

This class defines the base class for Firestore Pipeline functions, which can be evaluated within pipeline execution.

Selectable

Expressions that have an alias are Selectable

Known indirect subclasses
AliasedExpression

Represents an expression that will be given the alias in the output document.

Field

Represents a reference to a field in a Firestore document.


Represents an expression that can be evaluated to a value within the execution of a Pipeline.

Expressions are the building blocks for creating complex queries and transformations in Firestore pipelines. They can represent:

  • Field references: Access values from document fields.

  • Literals: Represent constant values (strings, numbers, booleans).

  • Function calls: Apply functions to one or more expressions.

The Expression class provides a fluent API for building expressions. You can chain together method calls to create complex expressions.

Summary

Nested types

public static class Expression.Companion

Public methods

final @NonNull Expression
abs()

Creates an expression that returns the absolute value of this expression.

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.

final @NonNull Expression

Creates an expression that adds this numeric expression to another numeric expression.

final @NonNull Expression
add(@NonNull Number second)

Creates an expression that adds this numeric expression to a constants.

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.

@NonNull AliasedExpression

Assigns an alias to this expression.

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.

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

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

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

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

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

Creates an expression that checks if 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

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

Creates an expression that checks if array contains any of 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.

final @NonNull Expression

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

final @NonNull Expression
arrayGet(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 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.

final @NonNull Expression

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

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.

final @NonNull Expression

Reverses the order of elements in the array.

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.

final @NonNull Expression

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

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.

final @NonNull BooleanExpression

Casts the expression to a BooleanExpression.

final @NonNull Ordering

Create an Ordering that sorts documents in ascending order based on value of this expression

final @NonNull AggregateFunction

Creates an aggregation that calculates the average (mean) of this numeric expression across multiple stage inputs.

final @NonNull Expression
bitAnd(@NonNull byte[] bitsOther)

Creates an expression that applies a bitwise AND operation with a constant.

final @NonNull Expression

Creates an expression that applies a bitwise AND operation with other expression.

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.

final @NonNull Expression
bitLeftShift(int number)

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

final @NonNull Expression

Creates an expression that applies a bitwise left shift operation with 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.

final @NonNull Expression

Creates an expression that applies a bitwise NOT operation to this 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.

final @NonNull Expression
bitOr(@NonNull byte[] bitsOther)

Creates an expression that applies a bitwise OR operation with a constant.

final @NonNull Expression
bitOr(@NonNull Expression bitsOther)

Creates an expression that applies a bitwise OR operation with other expression.

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.

final @NonNull Expression
bitRightShift(int number)

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

final @NonNull Expression

Creates an expression that applies a bitwise right shift operation with 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.

final @NonNull Expression
bitXor(@NonNull byte[] bitsOther)

Creates an expression that applies a bitwise XOR operation with a constant.

final @NonNull Expression

Creates an expression that applies a bitwise XOR operation with 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.

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

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.

final @NonNull Expression

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

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.

final @NonNull Expression

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

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.

final @NonNull Expression

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

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.

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

Creates an expression that concatenates this expression's value with others.

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

Creates an expression that concatenates this expression's value with others.

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.

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

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

final @NonNull Expression

Calculates the Cosine distance between this and another vector expressions.

final @NonNull Expression

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

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.

final @NonNull AggregateFunction

Creates an aggregation that counts the number of stage inputs with valid evaluations of the this expression.

final @NonNull AggregateFunction

Creates an aggregation that counts the number of distinct values of an expression across multiple stage inputs.

static final @NonNull Expression

Creates an expression that evaluates to the current server timestamp.

final @NonNull Ordering

Create an Ordering that sorts documents in descending order based on value of this expression

final @NonNull Expression

Creates an expression that divides this numeric expression by another numeric expression.

final @NonNull Expression
divide(@NonNull Number divisor)

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

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.

final @NonNull Expression

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

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.

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

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

final @NonNull Expression

Calculates the dot product distance between this and another vector expression.

final @NonNull Expression

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

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression

Creates an expression that checks if this and other expression are equal.

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression
equalAny(@NonNull Expression arrayExpression)

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

final @NonNull BooleanExpression

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

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 .

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

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

final @NonNull Expression

Calculates the Euclidean distance between this and another vector expression.

final @NonNull Expression

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

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.

final @NonNull BooleanExpression

Creates an expression that checks if this expression evaluates to a name of the field that exists.

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.

final @NonNull Expression
exp()

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

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.

final @NonNull Expression

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

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.

final @NonNull BooleanExpression

Creates an expression that checks if this expression is greater than the other expression.

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression

Creates an expression that checks if this expression is greater than or equal to the other expression.

final @NonNull BooleanExpression

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

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.

final @NonNull Expression

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

final @NonNull Expression
ifAbsent(@NonNull Object elseValue)

Creates an expression that returns the elseValue argument if this expression is absent, else return the result of this 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.

final @NonNull Expression

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

final @NonNull Expression
ifError(@NonNull Object catchValue)

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

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.

final @NonNull BooleanExpression

Creates an expression that returns true if the result of this expression is absent.

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.

final @NonNull BooleanExpression

Creates an expression that checks if this expression produces an error.

static final @NonNull BooleanExpression

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

final @NonNull Expression
join(@NonNull String delimiter)

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

final @NonNull Expression
join(@NonNull Expression delimiterExpression)

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

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.

final @NonNull Expression

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

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.

final @NonNull BooleanExpression

Creates an expression that checks if this expression is less than the other expression.

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression

Creates an expression that checks if this expression is less than or equal to the other expression.

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression
like(@NonNull String pattern)

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

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.

final @NonNull Expression
ln()

Creates an expression that returns the natural logarithm of this numeric expression.

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.

final @NonNull Expression

Creates an expression that returns the base-10 logarithm of this numeric expression.

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.

final @NonNull Expression

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

final @NonNull Expression

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 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.

final @NonNull Expression

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

final @NonNull Expression

Creates an expression that returns the smallest 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.

final @NonNull Expression

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

final @NonNull Expression
mapGet(@NonNull Expression keyExpression)

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

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.

final @NonNull Expression
mapMerge(@NonNull Expression mapExpr, @NonNull Expression otherMaps)

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

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.

final @NonNull Expression

Creates an expression that removes a key from this map expression.

final @NonNull Expression
mapRemove(@NonNull Expression keyExpression)

Creates an expression that removes a key from this map 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

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.

final @NonNull AggregateFunction

Creates an aggregation that finds the maximum value of this expression across multiple stage inputs.

final @NonNull AggregateFunction

Creates an aggregation that finds the minimum value of this expression across multiple stage inputs.

final @NonNull Expression

Creates an expression that calculates the modulo (remainder) of dividing this numeric expressions by another numeric expression.

final @NonNull Expression
mod(@NonNull Number divisor)

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

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.

final @NonNull Expression

Creates an expression that multiplies this numeric expression with another numeric expression.

final @NonNull Expression

Creates an expression that multiplies this numeric expression with 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.

final @NonNull BooleanExpression

Creates an expression that checks if this expressions is not equal to the other expression.

final @NonNull BooleanExpression

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

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.

final @NonNull BooleanExpression
notEqualAny(@NonNull Expression arrayExpression)

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

final @NonNull BooleanExpression

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

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.

final @NonNull Expression
pow(@NonNull Expression exponent)

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

final @NonNull Expression
pow(@NonNull Number exponent)

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

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

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

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 Expression
regexFind(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that returns the first substring of a string field that matches a specified regular expression.

static final @NonNull Expression
regexFind(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that returns the first substring of a string field that matches a specified regular expression.

static final @NonNull Expression
regexFind(
    @NonNull Expression stringExpression,
    @NonNull Expression pattern
)

Creates an expression that returns the first substring of a string expression that matches a specified regular expression.

static final @NonNull Expression
regexFind(@NonNull Expression stringExpression, @NonNull String pattern)

Creates an expression that returns the first substring of a string expression that matches a specified regular expression.

static final @NonNull Expression
regexFindAll(@NonNull String fieldName, @NonNull Expression pattern)

Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.

static final @NonNull Expression
regexFindAll(@NonNull String fieldName, @NonNull String pattern)

Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.

static final @NonNull Expression
regexFindAll(
    @NonNull Expression stringExpression,
    @NonNull Expression pattern
)

Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.

static final @NonNull Expression
regexFindAll(@NonNull Expression stringExpression, @NonNull String pattern)

Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

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

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.

final @NonNull Expression

Creates an expression that reverses this string 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.

final @NonNull Expression

Creates an expression that rounds this numeric expression to nearest integer.

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.

final @NonNull Expression

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

final @NonNull Expression
roundToPrecision(int decimalPlace)

Creates an expression that rounds off this numeric expression 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,
    @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.

final @NonNull Expression
split(@NonNull Blob delimiter)

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

final @NonNull Expression
split(@NonNull Expression delimiter)

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

final @NonNull Expression
split(@NonNull String delimiter)

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

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.

final @NonNull Expression

Creates an expression that returns the square root of this numeric expression.

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

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

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.

final @NonNull Expression
stringConcat(@NonNull Expression stringExpressions)

Creates an expression that concatenates string expressions together.

final @NonNull Expression

Creates an expression that concatenates string expressions and string constants together.

final @NonNull Expression

Creates an expression that concatenates this string expression with string constants.

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.

final @NonNull BooleanExpression

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

final @NonNull BooleanExpression

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

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.

final @NonNull Expression

Creates an expression that performs a reverse operation on this string expression.

static final @NonNull Expression

Reverses the given string field.

static final @NonNull Expression

Reverses the given string expression.

final @NonNull Expression

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

final @NonNull Expression
substring(int start, int length)

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

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.

final @NonNull Expression

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

final @NonNull Expression
subtract(@NonNull Number subtrahend)

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

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.

final @NonNull AggregateFunction
sum()

Creates an aggregation that calculates the sum of this numeric expression across multiple stage inputs.

final @NonNull Expression

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

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

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

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.

final @NonNull Expression

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

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

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

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.

final @NonNull Expression

Creates an expression that converts this 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 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).

final @NonNull Expression

Creates an expression that converts this 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 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).

final @NonNull Expression

Creates an expression that converts this 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 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).

final @NonNull Expression

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

final @NonNull Expression

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

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.

final @NonNull Expression

Creates an expression that converts this string expression to lowercase.

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.

final @NonNull Expression

Creates an expression that converts this string expression to uppercase.

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.

final @NonNull Expression

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

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.

final @NonNull Expression

Creates an expression that removes leading and trailing value from this expression.

final @NonNull Expression
trimValue(@NonNull String valueToTrim)

Creates an expression that removes leading and trailing characters from this 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.

final @NonNull Expression

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

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.

final @NonNull Expression

Creates an expression that interprets this 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 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.

final @NonNull Expression

Creates an expression that interprets this 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 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.

final @NonNull Expression

Creates an expression that interprets this 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 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.

final @NonNull Expression

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

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 final @NonNull Expression abs()

Creates an expression that returns the absolute value of this expression.

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

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

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 final @NonNull Expression add(@NonNull Expression second)

Creates an expression that adds this numeric expression to another numeric expression.

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

Numeric expression to add.

Returns
@NonNull Expression

A new Expression representing the addition operation.

add

public final @NonNull Expression add(@NonNull Number second)

Creates an expression that adds this numeric expression to a constants.

// Add 5 to the value of the 'quantity' field.
field("quantity").add(5)
Parameters
@NonNull Number second

Constant to add.

Returns
@NonNull Expression

A new Expression representing the addition 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.

alias

public @NonNull AliasedExpression alias(@NonNull String alias)

Assigns an alias to this expression.

Aliases are useful for renaming fields in the output of a stage or for giving meaningful names to calculated values.

Parameters
@NonNull String alias

The alias to assign to this expression.

Returns
@NonNull AliasedExpression

A AliasedExpression that wraps this expression and associates it with the provided alias.

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 final @NonNull Expression arrayConcat(@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.
field("items").arrayConcat(listOf("a", "b"))
Parameters
@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 final @NonNull Expression arrayConcat(@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.
field("items").arrayConcat(field("otherItems"))
Parameters
@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 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 final @NonNull BooleanExpression arrayContains(@NonNull Object element)

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

// Check if the 'colors' array contains "red"
field("colors").arrayContains("red")
Parameters
@NonNull Object element

The element to search for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContains operation.

arrayContains

public final @NonNull BooleanExpression arrayContains(@NonNull Expression element)

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

// Check if the 'sizes' array contains the value from the 'selectedSize' field
field("sizes").arrayContains(field("selectedSize"))
Parameters
@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 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 final @NonNull BooleanExpression arrayContainsAll(@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"
field("tags").arrayContainsAll(array(field("tag1"), "tag2"))
Parameters
@NonNull Expression arrayExpression

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAll

public final @NonNull BooleanExpression arrayContainsAll(@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"
field("tags").arrayContainsAll(listOf(field("tag1"), "tag2"))
Parameters
@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 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 final @NonNull BooleanExpression arrayContainsAny(@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"
field("groups").arrayContainsAny(array(field("userGroup"), "guest"))
Parameters
@NonNull Expression arrayExpression

The elements to check for in the array.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayContainsAny

public final @NonNull BooleanExpression arrayContainsAny(@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"
field("categories").arrayContainsAny(listOf(field("cate1"), field("cate2")))
Parameters
@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 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 final @NonNull Expression arrayGet(@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'.
field("tags").arrayGet(field("favoriteTag"))
Parameters
@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 final @NonNull Expression arrayGet(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`.
field("tags").arrayGet(1)
Parameters
int 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, @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 final @NonNull Expression arrayLength()

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

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

A new Expression representing the length of the array.

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 final @NonNull Expression arrayReverse()

Reverses the order of elements in the array.

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

A new Expression representing the arrayReverse operation.

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 final @NonNull Expression arraySum()

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

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

A new Expression representing the sum of the array elements.

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.

asBoolean

public final @NonNull BooleanExpression asBoolean()

Casts the expression to a BooleanExpression.

Returns
@NonNull BooleanExpression

A BooleanExpression representing the same expression.

ascending

public final @NonNull Ordering ascending()

Create an Ordering that sorts documents in ascending order based on value of this expression

Returns
@NonNull Ordering

A new Ordering object with ascending sort by this expression.

average

public final @NonNull AggregateFunction average()

Creates an aggregation that calculates the average (mean) of this numeric expression across multiple stage inputs.

Returns
@NonNull AggregateFunction

A new AggregateFunction representing the average aggregation.

bitAnd

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

Creates an expression that applies a bitwise AND operation with a constant.

// Bitwise AND the value of the 'flags' field with a constant mask.
field("flags").bitAnd(byteArrayOf(0b00001111))
Parameters
@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise AND operation.

bitAnd

public final @NonNull Expression bitAnd(@NonNull Expression bitsOther)

Creates an expression that applies a bitwise AND operation with other expression.

// Bitwise AND the value of the 'flags' field with the value of the 'mask' field.
field("flags").bitAnd(field("mask"))
Parameters
@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 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 final @NonNull Expression bitLeftShift(int number)

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

// Left shift the value of the 'bits' field by 2.
field("bits").bitLeftShift(2)
Parameters
int number

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise left shift operation.

bitLeftShift

public final @NonNull Expression bitLeftShift(@NonNull Expression numberExpr)

Creates an expression that applies a bitwise left shift operation with an expression.

// Left shift the value of the 'bits' field by the value of the 'shift' field.
field("bits").bitLeftShift(field("shift"))
Parameters
@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 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 final @NonNull Expression bitNot()

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

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

A new Expression representing the bitwise NOT 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 final @NonNull Expression bitOr(@NonNull byte[] bitsOther)

Creates an expression that applies a bitwise OR operation with a constant.

// Bitwise OR the value of the 'flags' field with a constant mask.
field("flags").bitOr(byteArrayOf(0b00001111))
Parameters
@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise OR operation.

bitOr

public final @NonNull Expression bitOr(@NonNull Expression bitsOther)

Creates an expression that applies a bitwise OR operation with other expression.

// Bitwise OR the value of the 'flags' field with the value of the 'mask' field.
field("flags").bitOr(field("mask"))
Parameters
@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 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 final @NonNull Expression bitRightShift(int number)

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

// Right shift the value of the 'bits' field by 2.
field("bits").bitRightShift(2)
Parameters
int number

The number of bits to shift.

Returns
@NonNull Expression

A new Expression representing the bitwise right shift operation.

bitRightShift

public final @NonNull Expression bitRightShift(@NonNull Expression numberExpr)

Creates an expression that applies a bitwise right shift operation with an expression.

// Right shift the value of the 'bits' field by the value of the 'shift' field.
field("bits").bitRightShift(field("shift"))
Parameters
@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 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 final @NonNull Expression bitXor(@NonNull byte[] bitsOther)

Creates an expression that applies a bitwise XOR operation with a constant.

// Bitwise XOR the value of the 'flags' field with a constant mask.
field("flags").bitXor(byteArrayOf(0b00001111))
Parameters
@NonNull byte[] bitsOther

A constant byte array.

Returns
@NonNull Expression

A new Expression representing the bitwise XOR operation.

bitXor

public final @NonNull Expression bitXor(@NonNull Expression bitsOther)

Creates an expression that applies a bitwise XOR operation with an expression.

// Bitwise XOR the value of the 'flags' field with the value of the 'mask' field.
field("flags").bitXor(field("mask"))
Parameters
@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 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 final @NonNull Expression byteLength()

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.
field("myString").byteLength()
Returns
@NonNull Expression

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

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 final @NonNull Expression ceil()

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

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

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

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 final @NonNull Expression charLength()

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

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

A new Expression representing the charLength 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 final @NonNull Expression collectionId()

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

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

A new Expression representing the collectionId 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 final @NonNull Expression concat(@NonNull Object second, @NonNull Object others)

Creates an expression that concatenates this expression's value with others. The values must be all strings, all arrays, or all blobs. Types cannot be mixed.

// Concatenate a field with a literal string.
field("firstName").concat("lastName")
Parameters
@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 final @NonNull Expression concat(@NonNull Expression second, @NonNull Object others)

Creates an expression that concatenates this expression's value with others. The values must be all strings, all arrays, or all blobs. Types cannot be mixed.

// Concatenate a field with another field.
field("firstName").concat(field("lastName"))
Parameters
@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 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 final @NonNull Expression cosineDistance(@NonNull double[] vector)

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

// Calculate the Cosine distance between the 'location' field and a target location
field("location").cosineDistance(doubleArrayOf(37.7749, -122.4194))
Parameters
@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 final @NonNull Expression cosineDistance(@NonNull Expression vector)

Calculates the Cosine distance between this and another vector expressions.

// Calculate the cosine distance between the 'userVector' field and the 'itemVector' field
field("userVector").cosineDistance(field("itemVector"))
Parameters
@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 final @NonNull Expression cosineDistance(@NonNull VectorValue vector)

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

// Calculate the Cosine distance between the 'location' field and a target location
field("location").cosineDistance(VectorValue.from(listOf(37.7749, -122.4194)))
Parameters
@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.

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.

count

public final @NonNull AggregateFunction count()

Creates an aggregation that counts the number of stage inputs with valid evaluations of the this expression.

Returns
@NonNull AggregateFunction

A new AggregateFunction representing the count aggregation.

countDistinct

public final @NonNull AggregateFunction countDistinct()

Creates an aggregation that counts the number of distinct values of an expression across multiple stage inputs.

Returns
@NonNull AggregateFunction

A new AggregateFunction representing the count distinct aggregation.

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.

descending

public final @NonNull Ordering descending()

Create an Ordering that sorts documents in descending order based on value of this expression

Returns
@NonNull Ordering

A new Ordering object with descending sort by this expression.

divide

public final @NonNull Expression divide(@NonNull Expression divisor)

Creates an expression that divides this numeric expression by another numeric expression.

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

Numeric expression to divide this numeric expression by.

Returns
@NonNull Expression

A new Expression representing the division operation.

divide

public final @NonNull Expression divide(@NonNull Number divisor)

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

// Divide the 'value' field by 10
field("value").divide(10)
Parameters
@NonNull Number divisor

Constant to divide this expression by.

Returns
@NonNull Expression

A new Expression representing the division operation.

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 final @NonNull Expression documentId()

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

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

A new Expression representing the documentId 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 final @NonNull Expression dotProduct(@NonNull double[] vector)

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

// Calculate the dot product between the 'vector' field and a constant vector
field
("vector").dotProduct(doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@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 final @NonNull Expression dotProduct(@NonNull Expression vector)

Calculates the dot product distance between this and another vector expression.

// Calculate the dot product between the 'userVector' field and the 'itemVector' field
field("userVector").dotProduct(field("itemVector"))
Parameters
@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 final @NonNull Expression dotProduct(@NonNull VectorValue vector)

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

// Calculate the dot product between the 'vector' field and a constant vector
field
("vector").dotProduct(VectorValue.from(listOf(1.0, 2.0, 3.0)))
Parameters
@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.

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 final @NonNull BooleanExpression endsWith(@NonNull Expression suffix)

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

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

The suffix string expression to check for.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith

public final @NonNull BooleanExpression endsWith(@NonNull String suffix)

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

// Check if the 'filename' field ends with ".txt"
field("filename").endsWith(".txt")
Parameters
@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 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 final @NonNull BooleanExpression equal(@NonNull Expression other)

Creates an expression that checks if this and other expression are equal.

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

The expression to compare to.

Returns
@NonNull BooleanExpression

A new BooleanExpression representing the equality comparison.

equal

public final @NonNull BooleanExpression equal(@NonNull Object value)

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

// Check if the 'age' field is equal to 21
field("age").equal(21)
Parameters
@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 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 final @NonNull BooleanExpression equalAny(@NonNull Expression arrayExpression)

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

// Check if the 'category' field is in the 'availableCategories' array field.
field("category").equalAny(field("availableCategories"))
Parameters
@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 final @NonNull BooleanExpression equalAny(@NonNull List<@NonNull Object> values)

Creates an expression that checks if this 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.
field("category").equalAny(listOf("Electronics", field("primaryType")))
Parameters
@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 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 final @NonNull Expression euclideanDistance(@NonNull double[] vector)

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

// Calculate the Euclidean distance between the 'vector' field and a constant vector
field
("vector").euclideanDistance(doubleArrayOf(1.0, 2.0, 3.0))
Parameters
@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 final @NonNull Expression euclideanDistance(@NonNull Expression vector)

Calculates the Euclidean distance between this and another vector expression.

// Calculate the Euclidean distance between the 'userVector' field and the 'itemVector' field
field("userVector").euclideanDistance(field("itemVector"))
Parameters
@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 final @NonNull Expression euclideanDistance(@NonNull VectorValue vector)

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

// Calculate the Euclidean distance between the 'vector' field and a constant vector
field
("vector").euclideanDistance(VectorValue.from(listOf(1.0, 2.0, 3.0)))
Parameters
@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.

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 final @NonNull BooleanExpression exists()

Creates an expression that checks if this expression evaluates to a name of the field that exists.

Returns
@NonNull BooleanExpression

A new Expression representing the exists check.

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 final @NonNull Expression exp()

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

// Compute e to the power of the 'value' field.
field("value").exp()
Returns
@NonNull Expression

A new Expression representing the numeric result of the exponentiation.

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 final @NonNull Expression floor()

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

// Compute the floor of the 'price' field.
field("price").floor()
Returns
@NonNull Expression

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

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