Class Expression (3.35.1)

public abstract class Expression

Represents an expression that can be evaluated to a value within the execution of a com.google.cloud.firestore.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.

Inheritance

Object > Expression

Static Methods

abs(Expression numericExpr)

public static Expression abs(Expression numericExpr)

Creates an expression that returns the absolute value of numericExpr.

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

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

abs(String numericField)

public static Expression abs(String numericField)

Creates an expression that returns the absolute value of numericField.

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

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

add(Expression first, Expression second)

public static Expression add(Expression first, Expression second)

Creates an expression that adds numeric expressions.

Parameters
Name Description
first Expression

Numeric expression to add.

second Expression

Numeric expression to add.

Returns
Type Description
Expression

A new Expression representing the addition operation.

add(Expression first, Number second)

public static Expression add(Expression first, Number second)

Creates an expression that adds numeric expressions with a constant.

Parameters
Name Description
first Expression

Numeric expression to add.

second Number

Constant to add.

Returns
Type Description
Expression

A new Expression representing the addition operation.

add(String fieldName, Expression second)

public static Expression add(String fieldName, Expression second)

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

Parameters
Name Description
fieldName String

Numeric field to add.

second Expression

Numeric expression to add to field value.

Returns
Type Description
Expression

A new Expression representing the addition operation.

add(String fieldName, Number second)

public static Expression add(String fieldName, Number second)

Creates an expression that adds a numeric field with constant.

Parameters
Name Description
fieldName String

Numeric field to add.

second Number

Constant to add.

Returns
Type Description
Expression

A new Expression representing the addition operation.

and(BooleanExpression condition, BooleanExpression[] conditions)

public static BooleanExpression and(BooleanExpression condition, BooleanExpression[] conditions)

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

Parameters
Name Description
condition BooleanExpression

The first BooleanExpression.

conditions BooleanExpression[]

Additional BooleanExpressions.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the logical 'AND' operation.

array(Object[] elements)

public static Expression array(Object[] elements)

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

Parameter
Name Description
elements Object[]

The input elements to evaluate in the expression.

Returns
Type Description
Expression

A new Expression representing the array function.

array(List<Object> elements)

public static Expression array(List<Object> elements)

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

Parameter
Name Description
elements List<Object>

The input elements to evaluate in the expression.

Returns
Type Description
Expression

A new Expression representing the array function.

arrayConcat(Expression firstArray, Object[] otherArrays)

public static Expression arrayConcat(Expression firstArray, Object[] otherArrays)

Creates an expression that concatenates multiple arrays into a single array.

Parameters
Name Description
firstArray Expression

The first array expression to concatenate.

otherArrays Object[]

Additional arrays to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated array.

arrayConcat(String firstArrayField, Object[] otherArrays)

public static Expression arrayConcat(String firstArrayField, Object[] otherArrays)

Creates an expression that concatenates multiple arrays into a single array.

Parameters
Name Description
firstArrayField String

The field name of the first array to concatenate.

otherArrays Object[]

Additional arrays to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated array.

arrayContains(Expression array, Expression element)

public static BooleanExpression arrayContains(Expression array, Expression element)

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

Parameters
Name Description
array Expression

The expression representing the array.

element Expression

The element to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains comparison.

arrayContains(Expression array, Object element)

public static BooleanExpression arrayContains(Expression array, Object element)

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

Parameters
Name Description
array Expression

The expression representing the array.

element Object

The element to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains comparison.

arrayContains(String arrayFieldName, Expression element)

public static BooleanExpression arrayContains(String arrayFieldName, Expression element)

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

element Expression

The element to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains comparison.

arrayContains(String arrayFieldName, Object element)

public static BooleanExpression arrayContains(String arrayFieldName, Object element)

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

element Object

The element to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains comparison.

arrayContainsAll(Expression array, Expression arrayExpression)

public static BooleanExpression arrayContainsAll(Expression array, Expression arrayExpression)

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

Parameters
Name Description
array Expression

The expression representing the array.

arrayExpression Expression

The expression representing the array of values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains all comparison.

arrayContainsAll(Expression array, List<Object> values)

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

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

Parameters
Name Description
array Expression

The expression representing the array.

values List<Object>

The values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains all comparison.

arrayContainsAll(String arrayFieldName, Expression arrayExpression)

public static BooleanExpression arrayContainsAll(String arrayFieldName, Expression arrayExpression)

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

arrayExpression Expression

The expression representing the array of values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains all comparison.

arrayContainsAll(String arrayFieldName, List<Object> values)

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

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

values List<Object>

The values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains all comparison.

arrayContainsAny(Expression array, Expression arrayExpression)

public static BooleanExpression arrayContainsAny(Expression array, Expression arrayExpression)

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

Parameters
Name Description
array Expression

The expression representing the array.

arrayExpression Expression

The expression representing the array of values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains any comparison.

arrayContainsAny(Expression array, List<Object> values)

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

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

Parameters
Name Description
array Expression

The expression representing the array.

values List<Object>

The values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains any comparison.

arrayContainsAny(String arrayFieldName, Expression arrayExpression)

public static BooleanExpression arrayContainsAny(String arrayFieldName, Expression arrayExpression)

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

arrayExpression Expression

The expression representing the array of values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains any comparison.

arrayContainsAny(String arrayFieldName, List<Object> values)

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

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

values List<Object>

The values to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the array contains any comparison.

arrayGet(Expression array, Expression offset)

public static Expression arrayGet(Expression array, Expression offset)

Creates an expression that returns an element from an array at a specified index.

Parameters
Name Description
array Expression

The expression representing the array.

offset Expression

The index of the element to return.

Returns
Type Description
Expression

A new Expression representing the element at the specified index.

arrayGet(Expression array, int offset)

public static Expression arrayGet(Expression array, int offset)

Creates an expression that returns an element from an array at a specified index.

Parameters
Name Description
array Expression

The expression representing the array.

offset int

The index of the element to return.

Returns
Type Description
Expression

A new Expression representing the element at the specified index.

arrayGet(String arrayFieldName, Expression offset)

public static Expression arrayGet(String arrayFieldName, Expression offset)

Creates an expression that returns an element from an array at a specified index.

Parameters
Name Description
arrayFieldName String

The field name of the array.

offset Expression

The index of the element to return.

Returns
Type Description
Expression

A new Expression representing the element at the specified index.

arrayGet(String arrayFieldName, int offset)

public static Expression arrayGet(String arrayFieldName, int offset)

Creates an expression that returns an element from an array at a specified index.

Parameters
Name Description
arrayFieldName String

The field name of the array.

offset int

The index of the element to return.

Returns
Type Description
Expression

A new Expression representing the element at the specified index.

arrayLength(Expression array)

public static Expression arrayLength(Expression array)

Creates an expression that returns the length of an array.

Parameter
Name Description
array Expression

The expression representing the array.

Returns
Type Description
Expression

A new Expression representing the length of the array.

arrayLength(String arrayFieldName)

public static Expression arrayLength(String arrayFieldName)

Creates an expression that returns the length of an array.

Parameter
Name Description
arrayFieldName String

The field name of the array.

Returns
Type Description
Expression

A new Expression representing the length of the array.

arrayReverse(Expression array)

public static Expression arrayReverse(Expression array)

Creates an expression that reverses an array.

Parameter
Name Description
array Expression

The expression representing the array to reverse.

Returns
Type Description
Expression

A new Expression representing the reversed array.

arrayReverse(String arrayFieldName)

public static Expression arrayReverse(String arrayFieldName)

Creates an expression that reverses an array.

Parameter
Name Description
arrayFieldName String

The field name of the array to reverse.

Returns
Type Description
Expression

A new Expression representing the reversed array.

arraySum(Expression array)

public static Expression arraySum(Expression array)

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

Parameter
Name Description
array Expression

The expression representing the array.

Returns
Type Description
Expression

A new Expression representing the sum of the elements of the array.

arraySum(String arrayFieldName)

public static Expression arraySum(String arrayFieldName)

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

Parameter
Name Description
arrayFieldName String

The field name of the array.

Returns
Type Description
Expression

A new Expression representing the sum of the elements of the array.

byteLength(Expression string)

public static Expression byteLength(Expression string)

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

Parameter
Name Description
string Expression

The expression representing the string.

Returns
Type Description
Expression

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

byteLength(String fieldName)

public static Expression byteLength(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.

Parameter
Name Description
fieldName String

The name of the field containing the string.

Returns
Type Description
Expression

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

ceil(Expression numericExpr)

public static Expression ceil(Expression numericExpr)

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

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

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

ceil(String numericField)

public static Expression ceil(String numericField)

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

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

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

charLength(Expression string)

public static Expression charLength(Expression string)

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

Parameter
Name Description
string Expression

The expression representing the string.

Returns
Type Description
Expression

A new Expression representing the charLength operation.

charLength(String fieldName)

public static Expression charLength(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field containing the string.

Returns
Type Description
Expression

A new Expression representing the charLength operation.

collectionId(Expression path)

public static Expression collectionId(Expression path)

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

Parameter
Name Description
path Expression

An expression the evaluates to document path.

Returns
Type Description
Expression

A new Expression representing the collectionId operation.

collectionId(String pathFieldName)

public static Expression collectionId(String pathFieldName)

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

Parameter
Name Description
pathFieldName String

The field name of the path.

Returns
Type Description
Expression

A new Expression representing the collectionId operation.

concat(Expression first, Object[] others)

public static Expression concat(Expression first, Object[] others)

Creates an expression that concatenates expressions together.

Parameters
Name Description
first Expression

The expression representing the initial value.

others Object[]

Optional additional expressions or constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated value.

concat(String fieldName, Object[] others)

public static Expression concat(String fieldName, Object[] others)

Creates an expression that concatenates expressions together.

Parameters
Name Description
fieldName String

The field name containing the initial value.

others Object[]

Optional additional expressions or constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated value.

conditional(BooleanExpression condition, Expression thenExpr, Expression elseExpr)

public static Expression conditional(BooleanExpression condition, Expression thenExpr, 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
Name Description
condition BooleanExpression

The condition to evaluate.

thenExpr Expression

The expression to evaluate if the condition is true.

elseExpr Expression

The expression to evaluate if the condition is false.

Returns
Type Description
Expression

A new Expression representing the conditional operation.

conditional(BooleanExpression condition, Object thenValue, Object elseValue)

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

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

Parameters
Name Description
condition BooleanExpression

The condition to evaluate.

thenValue Object

Value if the condition is true.

elseValue Object

Value if the condition is false.

Returns
Type Description
Expression

A new Expression representing the conditional operation.

constant(byte[] value)

public static Expression constant(byte[] value)

Create a constant for a bytes value.

Parameter
Name Description
value byte[]

The bytes value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(Timestamp value)

public static Expression constant(Timestamp value)

Create a constant for a Timestamp value.

Parameter
Name Description
value com.google.cloud.Timestamp

The Timestamp value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(Blob value)

public static Expression constant(Blob value)

Create a constant for a Blob value.

Parameter
Name Description
value Blob

The Blob value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(DocumentReference value)

public static Expression constant(DocumentReference value)

Create a constant for a DocumentReference value.

Parameter
Name Description
value DocumentReference

The DocumentReference value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(GeoPoint value)

public static Expression constant(GeoPoint value)

Create a constant for a GeoPoint value.

Parameter
Name Description
value GeoPoint

The GeoPoint value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(VectorValue value)

public static Expression constant(VectorValue value)

Create a constant for a VectorValue value.

Parameter
Name Description
value VectorValue

The VectorValue value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(Boolean value)

public static BooleanExpression constant(Boolean value)

Create a constant for a Boolean value.

Parameter
Name Description
value Boolean

The Boolean value.

Returns
Type Description
BooleanExpression

A new BooleanExpression constant instance.

constant(Number value)

public static Expression constant(Number value)

Create a constant for a Number value.

Parameter
Name Description
value Number

The Number value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(String value)

public static Expression constant(String value)

Create a constant for a String value.

Parameter
Name Description
value String

The String value.

Returns
Type Description
Expression

A new Expression constant instance.

constant(Date value)

public static Expression constant(Date value)

Create a constant for a Date value.

Parameter
Name Description
value Date

The Date value.

Returns
Type Description
Expression

A new Expression constant instance.

cosineDistance(Expression vector1, Expression vector2)

public static Expression cosineDistance(Expression vector1, Expression vector2)

Creates an expression that calculates the cosine distance between two vectors.

Parameters
Name Description
vector1 Expression

The first vector.

vector2 Expression

The second vector.

Returns
Type Description
Expression

A new Expression representing the cosine distance.

cosineDistance(Expression vector1, double[] vector2)

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

Creates an expression that calculates the cosine distance between two vectors.

Parameters
Name Description
vector1 Expression

The first vector.

vector2 double[]

The second vector.

Returns
Type Description
Expression

A new Expression representing the cosine distance.

cosineDistance(String vectorFieldName, Expression vector)

public static Expression cosineDistance(String vectorFieldName, Expression vector)

Creates an expression that calculates the cosine distance between two vectors.

Parameters
Name Description
vectorFieldName String

The field name of the first vector.

vector Expression

The second vector.

Returns
Type Description
Expression

A new Expression representing the cosine distance.

cosineDistance(String vectorFieldName, double[] vector)

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

Creates an expression that calculates the cosine distance between two vectors.

Parameters
Name Description
vectorFieldName String

The field name of the first vector.

vector double[]

The second vector.

Returns
Type Description
Expression

A new Expression representing the cosine distance.

currentTimestamp()

public static Expression currentTimestamp()

Creates an expression that returns the current timestamp.

Returns
Type Description
Expression

A new Expression representing the current timestamp.

divide(Expression dividend, Expression divisor)

public static Expression divide(Expression dividend, Expression divisor)

Creates an expression that divides two numeric expressions.

Parameters
Name Description
dividend Expression

The numeric expression to be divided.

divisor Expression

The numeric expression to divide by.

Returns
Type Description
Expression

A new Expression representing the division operation.

divide(Expression dividend, Number divisor)

public static Expression divide(Expression dividend, Number divisor)

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

Parameters
Name Description
dividend Expression

The numeric expression to be divided.

divisor Number

The constant to divide by.

Returns
Type Description
Expression

A new Expression representing the division operation.

divide(String fieldName, Expression divisor)

public static Expression divide(String fieldName, Expression divisor)

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

Parameters
Name Description
fieldName String

The numeric field name to be divided.

divisor Expression

The numeric expression to divide by.

Returns
Type Description
Expression

A new Expression representing the divide operation.

divide(String fieldName, Number divisor)

public static Expression divide(String fieldName, Number divisor)

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

Parameters
Name Description
fieldName String

The numeric field name to be divided.

divisor Number

The constant to divide by.

Returns
Type Description
Expression

A new Expression representing the divide operation.

documentId(DocumentReference docRef)

public static Expression documentId(DocumentReference docRef)

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

Parameter
Name Description
docRef DocumentReference

The DocumentReference.

Returns
Type Description
Expression

A new Expression representing the documentId operation.

documentId(Expression documentPath)

public static Expression documentId(Expression documentPath)

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

Parameter
Name Description
documentPath Expression

An expression the evaluates to document path.

Returns
Type Description
Expression

A new Expression representing the documentId operation.

documentId(String documentPath)

public static Expression documentId(String documentPath)

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

Parameter
Name Description
documentPath String

The string representation of the document path.

Returns
Type Description
Expression

A new Expression representing the documentId operation.

dotProduct(Expression vector1, Expression vector2)

public static Expression dotProduct(Expression vector1, Expression vector2)

Creates an expression that calculates the dot product of two vectors.

Parameters
Name Description
vector1 Expression

The first vector.

vector2 Expression

The second vector.

Returns
Type Description
Expression

A new Expression representing the dot product.

dotProduct(Expression vector1, double[] vector2)

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

Creates an expression that calculates the dot product of two vectors.

Parameters
Name Description
vector1 Expression

The first vector.

vector2 double[]

The second vector.

Returns
Type Description
Expression

A new Expression representing the dot product.

dotProduct(String vectorFieldName, Expression vector)

public static Expression dotProduct(String vectorFieldName, Expression vector)

Creates an expression that calculates the dot product of two vectors.

Parameters
Name Description
vectorFieldName String

The field name of the first vector.

vector Expression

The second vector.

Returns
Type Description
Expression

A new Expression representing the dot product.

dotProduct(String vectorFieldName, double[] vector)

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

Creates an expression that calculates the dot product of two vectors.

Parameters
Name Description
vectorFieldName String

The field name of the first vector.

vector double[]

The second vector.

Returns
Type Description
Expression

A new Expression representing the dot product.

endsWith(Expression string, Expression suffix)

public static BooleanExpression endsWith(Expression string, Expression suffix)

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

Parameters
Name Description
string Expression

The expression to check.

suffix Expression

The suffix string expression to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith(Expression string, String suffix)

public static BooleanExpression endsWith(Expression string, String suffix)

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

Parameters
Name Description
string Expression

The expression to check.

suffix String

The suffix string to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith(String fieldName, Expression suffix)

public static BooleanExpression endsWith(String fieldName, Expression suffix)

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

Parameters
Name Description
fieldName String

The name of field that contains a string to check.

suffix Expression

The suffix string expression to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

endsWith(String fieldName, String suffix)

public static BooleanExpression endsWith(String fieldName, String suffix)

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

Parameters
Name Description
fieldName String

The name of field that contains a string to check.

suffix String

The suffix string to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'ends with' comparison.

equal(Expression left, Expression right)

public static BooleanExpression equal(Expression left, Expression right)

Creates an expression that checks if two expressions are equal.

Parameters
Name Description
left Expression

The first expression.

right Expression

The second expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the equality comparison.

equal(Expression left, Object right)

public static BooleanExpression equal(Expression left, Object right)

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

Parameters
Name Description
left Expression

The expression.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the equality comparison.

equal(String fieldName, Expression right)

public static BooleanExpression equal(String fieldName, Expression right)

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

Parameters
Name Description
fieldName String

The field name.

right Expression

The expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the equality comparison.

equal(String fieldName, Object right)

public static BooleanExpression equal(String fieldName, Object right)

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

Parameters
Name Description
fieldName String

The field name.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the equality comparison.

equalAny(Expression expression, Expression arrayExpression)

public static BooleanExpression equalAny(Expression expression, Expression arrayExpression)

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

Parameters
Name Description
expression Expression

The expression whose results to compare.

arrayExpression Expression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

equalAny(Expression expression, List<Object> values)

public static BooleanExpression equalAny(Expression expression, List<Object> values)

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

Parameters
Name Description
expression Expression

The expression whose results to compare.

values List<Object>

The values to check against.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

equalAny(String fieldName, Expression arrayExpression)

public static BooleanExpression equalAny(String fieldName, Expression arrayExpression)

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

Parameters
Name Description
fieldName String

The field to compare.

arrayExpression Expression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

equalAny(String fieldName, List<Object> values)

public static BooleanExpression equalAny(String fieldName, List<Object> values)

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

Parameters
Name Description
fieldName String

The field to compare.

values List<Object>

The values to check against.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

euclideanDistance(Expression vector1, Expression vector2)

public static Expression euclideanDistance(Expression vector1, Expression vector2)

Creates an expression that calculates the Euclidean distance between two vectors.

Parameters
Name Description
vector1 Expression

The first vector.

vector2 Expression

The second vector.

Returns
Type Description
Expression

A new Expression representing the Euclidean distance.

euclideanDistance(Expression vector1, double[] vector2)

public static Expression euclideanDistance(Expression vector1, double[] vector2)

Creates an expression that calculates the Euclidean distance between two vectors.

Parameters
Name Description
vector1 Expression

The first vector.

vector2 double[]

The second vector.

Returns
Type Description
Expression

A new Expression representing the Euclidean distance.

euclideanDistance(String vectorFieldName, Expression vector)

public static Expression euclideanDistance(String vectorFieldName, Expression vector)

Creates an expression that calculates the Euclidean distance between two vectors.

Parameters
Name Description
vectorFieldName String

The field name of the first vector.

vector Expression

The second vector.

Returns
Type Description
Expression

A new Expression representing the Euclidean distance.

euclideanDistance(String vectorFieldName, double[] vector)

public static Expression euclideanDistance(String vectorFieldName, double[] vector)

Creates an expression that calculates the Euclidean distance between two vectors.

Parameters
Name Description
vectorFieldName String

The field name of the first vector.

vector double[]

The second vector.

Returns
Type Description
Expression

A new Expression representing the Euclidean distance.

exists(Expression value)

public static BooleanExpression exists(Expression value)

Creates an expression that checks if a field exists.

Parameter
Name Description
value Expression

An expression evaluates to the name of the field to check.

Returns
Type Description
BooleanExpression

A new Expression representing the exists check.

exists(String fieldName)

public static BooleanExpression exists(String fieldName)

Creates an expression that checks if a field exists.

Parameter
Name Description
fieldName String

The field name to check.

Returns
Type Description
BooleanExpression

A new Expression representing the exists check.

exp(Expression numericExpr)

public static Expression exp(Expression numericExpr)

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

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the exponentiation.

exp(String numericField)

public static Expression exp(String numericField)

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

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the exponentiation.

field(FieldPath fieldPath)

public static Field field(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").

Parameter
Name Description
fieldPath FieldPath

The FieldPath to the field.

Returns
Type Description
Field

A new Field instance representing the specified path.

field(String path)

public static Field field(String path)

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

Parameter
Name Description
path String

The path to the field.

Returns
Type Description
Field

A new Field instance representing the specified path.

floor(Expression numericExpr)

public static Expression floor(Expression numericExpr)

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

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

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

floor(String numericField)

public static Expression floor(String numericField)

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

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

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

greaterThan(Expression left, Expression right)

public static BooleanExpression greaterThan(Expression left, Expression right)

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

Parameters
Name Description
left Expression

The first expression.

right Expression

The second expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThan(Expression left, Object right)

public static BooleanExpression greaterThan(Expression left, Object right)

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

Parameters
Name Description
left Expression

The expression.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThan(String fieldName, Expression right)

public static BooleanExpression greaterThan(String fieldName, Expression right)

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

Parameters
Name Description
fieldName String

The field name.

right Expression

The expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThan(String fieldName, Object right)

public static BooleanExpression greaterThan(String fieldName, Object right)

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

Parameters
Name Description
fieldName String

The field name.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThanOrEqual(Expression left, Expression right)

public static BooleanExpression greaterThanOrEqual(Expression left, Expression right)

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

Parameters
Name Description
left Expression

The first expression.

right Expression

The second expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

greaterThanOrEqual(Expression left, Object right)

public static BooleanExpression greaterThanOrEqual(Expression left, Object right)

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

Parameters
Name Description
left Expression

The expression.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

greaterThanOrEqual(String fieldName, Expression right)

public static BooleanExpression greaterThanOrEqual(String fieldName, Expression right)

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

Parameters
Name Description
fieldName String

The field name.

right Expression

The expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

greaterThanOrEqual(String fieldName, Object right)

public static BooleanExpression greaterThanOrEqual(String fieldName, Object right)

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

Parameters
Name Description
fieldName String

The field name.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

ifAbsent(Expression ifExpr, Expression elseExpr)

public static Expression ifAbsent(Expression ifExpr, Expression elseExpr)

Creates an expression that returns a default value if an expression evaluates to an absent value.

Parameters
Name Description
ifExpr Expression

The expression to check.

elseExpr Expression

The default value.

Returns
Type Description
Expression

A new Expression representing the ifAbsent operation.

ifAbsent(Expression ifExpr, Object elseValue)

public static Expression ifAbsent(Expression ifExpr, Object elseValue)

Creates an expression that returns a default value if an expression evaluates to an absent value.

Parameters
Name Description
ifExpr Expression

The expression to check.

elseValue Object

The default value.

Returns
Type Description
Expression

A new Expression representing the ifAbsent operation.

ifAbsent(String ifFieldName, Expression elseExpr)

public static Expression ifAbsent(String ifFieldName, Expression elseExpr)

Creates an expression that returns a default value if a field is absent.

Parameters
Name Description
ifFieldName String

The field to check.

elseExpr Expression

The default value.

Returns
Type Description
Expression

A new Expression representing the ifAbsent operation.

ifAbsent(String ifFieldName, Object elseValue)

public static Expression ifAbsent(String ifFieldName, Object elseValue)

Creates an expression that returns a default value if a field is absent.

Parameters
Name Description
ifFieldName String

The field to check.

elseValue Object

The default value.

Returns
Type Description
Expression

A new Expression representing the ifAbsent operation.

ifError(BooleanExpression tryExpr, BooleanExpression catchExpr)

public static BooleanExpression ifError(BooleanExpression tryExpr, BooleanExpression catchExpr)

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

This overload will return BooleanExpression when both parameters are also BooleanExpression.

Parameters
Name Description
tryExpr BooleanExpression

The try boolean expression.

catchExpr BooleanExpression

The catch boolean expression that will be evaluated and returned if the tryExpr produces an error.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the ifError operation.

ifError(Expression tryExpr, Expression catchExpr)

public static Expression ifError(Expression tryExpr, Expression catchExpr)

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

Parameters
Name Description
tryExpr Expression

The try expression.

catchExpr Expression

The catch expression that will be evaluated and returned if the tryExpr produces an error.

Returns
Type Description
Expression

A new Expression representing the ifError operation.

ifError(Expression tryExpr, Object catchValue)

public static Expression ifError(Expression tryExpr, Object catchValue)

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

Parameters
Name Description
tryExpr Expression

The try expression.

catchValue Object

The value that will be returned if the tryExpr produces an error.

Returns
Type Description
Expression

A new Expression representing the ifError operation.

isAbsent(Expression value)

public static BooleanExpression isAbsent(Expression value)

Creates an expression that returns true if a value is absent. Otherwise, returns false even if the value is null.

Parameter
Name Description
value Expression

The expression to check.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isAbsent operation.

isAbsent(String fieldName)

public static BooleanExpression isAbsent(String fieldName)

Creates an expression that returns true if a field is absent. Otherwise, returns false even if the field value is null.

Parameter
Name Description
fieldName String

The field to check.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isAbsent operation.

isError(Expression expr)

public static BooleanExpression isError(Expression expr)

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

Parameter
Name Description
expr Expression

The expression to check.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isError check.

isNotNaN(Expression expr)

public static BooleanExpression isNotNaN(Expression expr)

Creates an expression that checks if the results of expr is NOT 'NaN' (Not a Number).

Parameter
Name Description
expr Expression

The expression to check.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isNotNan operation.

isNotNaN(String fieldName)

public static BooleanExpression isNotNaN(String fieldName)

Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).

Parameter
Name Description
fieldName String

The field to check.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isNotNan operation.

join(Expression arrayExpression, Expression delimiterExpression)

public static Expression join(Expression arrayExpression, Expression delimiterExpression)

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

Parameters
Name Description
arrayExpression Expression

The expression representing the array.

delimiterExpression Expression

The expression representing the delimiter.

Returns
Type Description
Expression

A new Expression representing the join operation.

join(Expression arrayExpression, String delimiter)

public static Expression join(Expression arrayExpression, String delimiter)

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

Parameters
Name Description
arrayExpression Expression

The expression representing the array.

delimiter String

The delimiter to use.

Returns
Type Description
Expression

A new Expression representing the join operation.

join(String arrayFieldName, Expression delimiterExpression)

public static Expression join(String arrayFieldName, Expression delimiterExpression)

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

delimiterExpression Expression

The expression representing the delimiter.

Returns
Type Description
Expression

A new Expression representing the join operation.

join(String arrayFieldName, String delimiter)

public static Expression join(String arrayFieldName, String delimiter)

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

Parameters
Name Description
arrayFieldName String

The field name of the array.

delimiter String

The delimiter to use.

Returns
Type Description
Expression

A new Expression representing the join operation.

length(Expression string)

public static Expression length(Expression string)

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

Parameter
Name Description
string Expression

The expression representing the value to calculate the length of.

Returns
Type Description
Expression

A new Expression representing the length of the value.

length(String fieldName)

public static Expression length(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field containing the value.

Returns
Type Description
Expression

A new Expression representing the length of the value.

lessThan(Expression left, Expression right)

public static BooleanExpression lessThan(Expression left, Expression right)

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

Parameters
Name Description
left Expression

The first expression.

right Expression

The second expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThan(Expression left, Object right)

public static BooleanExpression lessThan(Expression left, Object right)

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

Parameters
Name Description
left Expression

The expression.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThan(String fieldName, Expression right)

public static BooleanExpression lessThan(String fieldName, Expression right)

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

Parameters
Name Description
fieldName String

The field name.

right Expression

The expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThan(String fieldName, Object right)

public static BooleanExpression lessThan(String fieldName, Object right)

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

Parameters
Name Description
fieldName String

The field name.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThanOrEqual(Expression left, Expression right)

public static BooleanExpression lessThanOrEqual(Expression left, Expression right)

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

Parameters
Name Description
left Expression

The first expression.

right Expression

The second expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

lessThanOrEqual(Expression left, Object right)

public static BooleanExpression lessThanOrEqual(Expression left, Object right)

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

Parameters
Name Description
left Expression

The expression.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

lessThanOrEqual(String fieldName, Expression right)

public static BooleanExpression lessThanOrEqual(String fieldName, Expression right)

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

Parameters
Name Description
fieldName String

The field name.

right Expression

The expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

lessThanOrEqual(String fieldName, Object right)

public static BooleanExpression lessThanOrEqual(String fieldName, Object right)

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

Parameters
Name Description
fieldName String

The field name.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

like(Expression string, Expression pattern)

public static BooleanExpression like(Expression string, Expression pattern)

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

Parameters
Name Description
string Expression

The expression representing the string to perform the comparison on.

pattern Expression

The pattern to search for. You can use "%" as a wildcard character.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the like operation.

like(Expression string, String pattern)

public static BooleanExpression like(Expression string, String pattern)

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

Parameters
Name Description
string Expression

The expression representing the string to perform the comparison on.

pattern String

The pattern to search for. You can use "%" as a wildcard character.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the like operation.

like(String fieldName, Expression pattern)

public static BooleanExpression like(String fieldName, Expression pattern)

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

Parameters
Name Description
fieldName String

The name of the field containing the string.

pattern Expression

The pattern to search for. You can use "%" as a wildcard character.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the like comparison.

like(String fieldName, String pattern)

public static BooleanExpression like(String fieldName, String pattern)

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

Parameters
Name Description
fieldName String

The name of the field containing the string.

pattern String

The pattern to search for. You can use "%" as a wildcard character.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the like comparison.

ln(Expression numericExpr)

public static Expression ln(Expression numericExpr)

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

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the natural logarithm.

ln(String numericField)

public static Expression ln(String numericField)

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

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the natural logarithm.

log(Expression numericExpr, Expression base)

public static Expression log(Expression numericExpr, Expression base)

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

Parameters
Name Description
numericExpr Expression

An expression that returns number when evaluated.

base Expression

The base of the logarithm.

Returns
Type Description
Expression

A new Expression representing a numeric result from the logarithm of numericExpr with a given base.

log(Expression numericExpr, Number base)

public static Expression log(Expression numericExpr, Number base)

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

Parameters
Name Description
numericExpr Expression

An expression that returns number when evaluated.

base Number

The base of the logarithm.

Returns
Type Description
Expression

A new Expression representing a numeric result from the logarithm of numericExpr with a given base.

log(String numericField, Expression base)

public static Expression log(String numericField, Expression base)

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

Parameters
Name Description
numericField String

Name of field that returns number when evaluated.

base Expression

The base of the logarithm.

Returns
Type Description
Expression

A new Expression representing a numeric result from the logarithm of numericField with a given base.

log(String numericField, Number base)

public static Expression log(String numericField, Number base)

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

Parameters
Name Description
numericField String

Name of field that returns number when evaluated.

base Number

The base of the logarithm.

Returns
Type Description
Expression

A new Expression representing a numeric result from the logarithm of numericField with a given base.

log10(Expression numericExpr)

public static Expression log10(Expression numericExpr)

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

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the base 10 logarithm.

log10(String numericField)

public static Expression log10(String numericField)

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

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the base 10 logarithm.

logicalMaximum(Expression expr, Object[] others)

public static Expression logicalMaximum(Expression expr, Object[] others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

Parameters
Name Description
expr Expression

The first operand expression.

others Object[]

Optional additional expressions or literals.

Returns
Type Description
Expression

A new Expression representing the logical maximum operation.

logicalMaximum(String fieldName, Object[] others)

public static Expression logicalMaximum(String fieldName, Object[] others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

Parameters
Name Description
fieldName String

The first operand field name.

others Object[]

Optional additional expressions or literals.

Returns
Type Description
Expression

A new Expression representing the logical maximum operation.

logicalMinimum(Expression expr, Object[] others)

public static Expression logicalMinimum(Expression expr, Object[] others)

Creates an expression that returns the smallest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

Parameters
Name Description
expr Expression

The first operand expression.

others Object[]

Optional additional expressions or literals.

Returns
Type Description
Expression

A new Expression representing the logical minimum operation.

logicalMinimum(String fieldName, Object[] others)

public static Expression logicalMinimum(String fieldName, Object[] others)

Creates an expression that returns the smallest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

Parameters
Name Description
fieldName String

The first operand field name.

others Object[]

Optional additional expressions or literals.

Returns
Type Description
Expression

A new Expression representing the logical minimum operation.

map(Map<String,Object> elements)

public static Expression map(Map<String,Object> elements)

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

Parameter
Name Description
elements Map<String,Object>

The input map to evaluate in the expression.

Returns
Type Description
Expression

A new Expression representing the map function.

mapGet(Expression map, Expression key)

public static Expression mapGet(Expression map, Expression key)

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

Parameters
Name Description
map Expression

The expression representing the map.

key Expression

The key to access in the map.

Returns
Type Description
Expression

A new Expression representing the value associated with the given key in the map.

mapGet(Expression map, String key)

public static Expression mapGet(Expression map, String key)

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

Parameters
Name Description
map Expression

The expression representing the map.

key String

The key to access in the map.

Returns
Type Description
Expression

A new Expression representing the value associated with the given key in the map.

mapGet(String fieldName, Expression key)

public static Expression mapGet(String fieldName, Expression key)

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

Parameters
Name Description
fieldName String

The field name of the map field.

key Expression

The key to access in the map.

Returns
Type Description
Expression

A new Expression representing the value associated with the given key in the map.

mapGet(String fieldName, String key)

public static Expression mapGet(String fieldName, String key)

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

Parameters
Name Description
fieldName String

The field name of the map field.

key String

The key to access in the map.

Returns
Type Description
Expression

A new Expression representing the value associated with the given key in the map.

mapMerge(Expression firstMap, Expression secondMap)

public static Expression mapMerge(Expression firstMap, Expression secondMap)
Parameters
Name Description
firstMap Expression
secondMap Expression
Returns
Type Description
Expression

mapMerge(Expression firstMap, Expression secondMap, Expression[] otherMaps)

public static Expression mapMerge(Expression firstMap, Expression secondMap, Expression[] otherMaps)

Creates an expression that merges multiple maps into a single map. If multiple maps have the same key, the later value is used.

Parameters
Name Description
firstMap Expression

First map expression that will be merged.

secondMap Expression

Second map expression that will be merged.

otherMaps Expression[]

Additional maps to merge.

Returns
Type Description
Expression

A new Expression representing the mapMerge operation.

mapMerge(String firstMapFieldName, Expression secondMap)

public static Expression mapMerge(String firstMapFieldName, Expression secondMap)
Parameters
Name Description
firstMapFieldName String
secondMap Expression
Returns
Type Description
Expression

mapMerge(String firstMapFieldName, Expression secondMap, Expression[] otherMaps)

public static Expression mapMerge(String firstMapFieldName, Expression secondMap, Expression[] otherMaps)

Creates an expression that merges multiple maps into a single map. If multiple maps have the same key, the later value is used.

Parameters
Name Description
firstMapFieldName String

Field name of the first map expression that will be merged.

secondMap Expression

Second map expression that will be merged.

otherMaps Expression[]

Additional maps to merge.

Returns
Type Description
Expression

A new Expression representing the mapMerge operation.

mapRemove(Expression mapExpr, Expression key)

public static Expression mapRemove(Expression mapExpr, Expression key)

Creates an expression that removes a key from a map.

Parameters
Name Description
mapExpr Expression

The expression representing the map.

key Expression

The key to remove from the map.

Returns
Type Description
Expression

A new Expression representing the map with the key removed.

mapRemove(Expression mapExpr, String key)

public static Expression mapRemove(Expression mapExpr, String key)

Creates an expression that removes a key from a map.

Parameters
Name Description
mapExpr Expression

The expression representing the map.

key String

The key to remove from the map.

Returns
Type Description
Expression

A new Expression representing the map with the key removed.

mapRemove(String mapField, Expression key)

public static Expression mapRemove(String mapField, Expression key)

Creates an expression that removes a key from a map.

Parameters
Name Description
mapField String

The field name of the map.

key Expression

The key to remove from the map.

Returns
Type Description
Expression

A new Expression representing the map with the key removed.

mapRemove(String mapField, String key)

public static Expression mapRemove(String mapField, String key)

Creates an expression that removes a key from a map.

Parameters
Name Description
mapField String

The field name of the map.

key String

The key to remove from the map.

Returns
Type Description
Expression

A new Expression representing the map with the key removed.

mod(Expression dividend, Expression divisor)

public static Expression mod(Expression dividend, Expression divisor)

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

Parameters
Name Description
dividend Expression

The numeric expression to be divided.

divisor Expression

The numeric expression to divide by.

Returns
Type Description
Expression

A new Expression representing the modulo operation.

mod(Expression dividend, Number divisor)

public static Expression mod(Expression dividend, Number divisor)

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

Parameters
Name Description
dividend Expression

The numeric expression to be divided.

divisor Number

The constant to divide by.

Returns
Type Description
Expression

A new Expression representing the modulo operation.

mod(String fieldName, Expression divisor)

public static Expression mod(String fieldName, Expression divisor)

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

Parameters
Name Description
fieldName String

The numeric field name to be divided.

divisor Expression

The numeric expression to divide by.

Returns
Type Description
Expression

A new Expression representing the modulo operation.

mod(String fieldName, Number divisor)

public static Expression mod(String fieldName, Number divisor)

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

Parameters
Name Description
fieldName String

The numeric field name to be divided.

divisor Number

The constant to divide by.

Returns
Type Description
Expression

A new Expression representing the modulo operation.

multiply(Expression first, Expression second)

public static Expression multiply(Expression first, Expression second)

Creates an expression that multiplies numeric expressions.

Parameters
Name Description
first Expression

Numeric expression to multiply.

second Expression

Numeric expression to multiply.

Returns
Type Description
Expression

A new Expression representing the multiplication operation.

multiply(Expression first, Number second)

public static Expression multiply(Expression first, Number second)

Creates an expression that multiplies numeric expressions with a constant.

Parameters
Name Description
first Expression

Numeric expression to multiply.

second Number

Constant to multiply.

Returns
Type Description
Expression

A new Expression representing the multiplication operation.

multiply(String fieldName, Expression second)

public static Expression multiply(String fieldName, Expression second)

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

Parameters
Name Description
fieldName String

Numeric field to multiply.

second Expression

Numeric expression to multiply.

Returns
Type Description
Expression

A new Expression representing the multiplication operation.

multiply(String fieldName, Number second)

public static Expression multiply(String fieldName, Number second)

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

Parameters
Name Description
fieldName String

Numeric field to multiply.

second Number

Constant to multiply.

Returns
Type Description
Expression

A new Expression representing the multiplication operation.

not(BooleanExpression condition)

public static BooleanExpression not(BooleanExpression condition)

Creates an expression that negates a boolean expression.

Parameter
Name Description
condition BooleanExpression

The boolean expression to negate.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the not operation.

notEqual(Expression left, Expression right)

public static BooleanExpression notEqual(Expression left, Expression right)

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

Parameters
Name Description
left Expression

The first expression.

right Expression

The second expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqual(Expression left, Object right)

public static BooleanExpression notEqual(Expression left, Object right)

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

Parameters
Name Description
left Expression

The expression.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqual(String fieldName, Expression right)

public static BooleanExpression notEqual(String fieldName, Expression right)

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

Parameters
Name Description
fieldName String

The field name.

right Expression

The expression.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqual(String fieldName, Object right)

public static BooleanExpression notEqual(String fieldName, Object right)

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

Parameters
Name Description
fieldName String

The field name.

right Object

The constant value.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqualAny(Expression expression, Expression arrayExpression)

public static BooleanExpression notEqualAny(Expression expression, Expression arrayExpression)

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

Parameters
Name Description
expression Expression

The expression whose results to compare.

arrayExpression Expression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

notEqualAny(Expression expression, List<Object> values)

public static BooleanExpression notEqualAny(Expression expression, List<Object> values)

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

Parameters
Name Description
expression Expression

The expression whose results to compare.

values List<Object>

The values to check against.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

notEqualAny(String fieldName, Expression arrayExpression)

public static BooleanExpression notEqualAny(String fieldName, Expression arrayExpression)

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

Parameters
Name Description
fieldName String

The field to compare.

arrayExpression Expression

An expression that evaluates to an array, whose elements to check for equality to the input.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

notEqualAny(String fieldName, List<Object> values)

public static BooleanExpression notEqualAny(String fieldName, List<Object> values)

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

Parameters
Name Description
fieldName String

The field to compare.

values List<Object>

The values to check against.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

nullValue()

public static Expression nullValue()

Constant for a null value.

Returns
Type Description
Expression

An Expression constant instance.

or(BooleanExpression condition, BooleanExpression[] conditions)

public static BooleanExpression or(BooleanExpression condition, BooleanExpression[] conditions)

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

Parameters
Name Description
condition BooleanExpression

The first BooleanExpression.

conditions BooleanExpression[]

Additional BooleanExpressions.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the logical 'OR' operation.

pow(Expression numericExpr, Expression exponent)

public static Expression pow(Expression numericExpr, Expression exponent)

Creates an expression that returns the numericExpr raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

Parameters
Name Description
numericExpr Expression

An expression that returns number when evaluated.

exponent Expression

The numeric power to raise the numericExpr.

Returns
Type Description
Expression

A new Expression representing a numeric result from raising numericExpr to the power of exponent.

pow(Expression numericExpr, Number exponent)

public static Expression pow(Expression numericExpr, Number exponent)

Creates an expression that returns the numericExpr raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

Parameters
Name Description
numericExpr Expression

An expression that returns number when evaluated.

exponent Number

The numeric power to raise the numericExpr.

Returns
Type Description
Expression

A new Expression representing a numeric result from raising numericExpr to the power of exponent.

pow(String numericField, Expression exponent)

public static Expression pow(String numericField, Expression exponent)

Creates an expression that returns the numericField raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

Parameters
Name Description
numericField String

Name of field that returns number when evaluated.

exponent Expression

The numeric power to raise the numericField.

Returns
Type Description
Expression

A new Expression representing a numeric result from raising numericField to the power of exponent.

pow(String numericField, Number exponent)

public static Expression pow(String numericField, Number exponent)

Creates an expression that returns the numericField raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

Parameters
Name Description
numericField String

Name of field that returns number when evaluated.

exponent Number

The numeric power to raise the numericField.

Returns
Type Description
Expression

A new Expression representing a numeric result from raising numericField to the power of exponent.

rawExpression(String name, Expression[] expr)

public static Expression rawExpression(String name, Expression[] expr)

Creates a generic function expression that is not yet implemented.

Parameters
Name Description
name String

The name of the generic function.

expr Expression[]

The expressions to be passed as arguments to the function.

Returns
Type Description
Expression

A new Expression representing the generic function.

regexContains(Expression string, Expression pattern)

public static BooleanExpression regexContains(Expression string, Expression pattern)

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

Parameters
Name Description
string Expression

The expression representing the string to perform the comparison on.

pattern Expression

The regular expression to use for the search.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexContains(Expression string, String pattern)

public static BooleanExpression regexContains(Expression string, String pattern)

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

Parameters
Name Description
string Expression

The expression representing the string to perform the comparison on.

pattern String

The regular expression to use for the search.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexContains(String fieldName, Expression pattern)

public static BooleanExpression regexContains(String fieldName, Expression pattern)

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

Parameters
Name Description
fieldName String

The name of the field containing the string.

pattern Expression

The regular expression to use for the search.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexContains(String fieldName, String pattern)

public static BooleanExpression regexContains(String fieldName, String pattern)

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

Parameters
Name Description
fieldName String

The name of the field containing the string.

pattern String

The regular expression to use for the search.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexMatch(Expression string, Expression pattern)

public static BooleanExpression regexMatch(Expression string, Expression pattern)

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

Parameters
Name Description
string Expression

The expression representing the string to match against.

pattern Expression

The regular expression to use for the match.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

regexMatch(Expression string, String pattern)

public static BooleanExpression regexMatch(Expression string, String pattern)

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

Parameters
Name Description
string Expression

The expression representing the string to match against.

pattern String

The regular expression to use for the match.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

regexMatch(String fieldName, Expression pattern)

public static BooleanExpression regexMatch(String fieldName, Expression pattern)

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

Parameters
Name Description
fieldName String

The name of the field containing the string.

pattern Expression

The regular expression to use for the match.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

regexMatch(String fieldName, String pattern)

public static BooleanExpression regexMatch(String fieldName, String pattern)

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

Parameters
Name Description
fieldName String

The name of the field containing the string.

pattern String

The regular expression to use for the match.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

reverse(Expression expr)

public static Expression reverse(Expression expr)

Creates an expression that reverses a string, blob, or array.

Parameter
Name Description
expr Expression

An expression evaluating to a string, blob, or array value, which will be reversed.

Returns
Type Description
Expression

A new Expression representing the reversed value.

reverse(String fieldName)

public static Expression reverse(String fieldName)

Creates an expression that reverses the field value, which must be a string, blob, or array.

Parameter
Name Description
fieldName String

A field evaluating to a string, blob, or array value.

Returns
Type Description
Expression

A new Expression representing the reversed value.

round(Expression numericExpr)

public static Expression round(Expression numericExpr)

Creates an expression that rounds numericExpr to nearest integer.

Rounds away from zero in halfway cases.

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

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

round(String numericField)

public static Expression round(String numericField)

Creates an expression that rounds numericField to nearest integer.

Rounds away from zero in halfway cases.

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

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

roundToPrecision(Expression numericExpr, Expression decimalPlace)

public static Expression roundToPrecision(Expression numericExpr, Expression decimalPlace)

Creates an expression that rounds off numericExpr to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

Parameters
Name Description
numericExpr Expression

An expression that returns number when evaluated.

decimalPlace Expression

The number of decimal places to round.

Returns
Type Description
Expression

A new Expression representing the round operation.

roundToPrecision(Expression numericExpr, int decimalPlace)

public static Expression roundToPrecision(Expression numericExpr, int decimalPlace)

Creates an expression that rounds off numericExpr to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

Parameters
Name Description
numericExpr Expression

An expression that returns number when evaluated.

decimalPlace int

The number of decimal places to round.

Returns
Type Description
Expression

A new Expression representing the round operation.

roundToPrecision(String numericField, Expression decimalPlace)

public static Expression roundToPrecision(String numericField, Expression decimalPlace)

Creates an expression that rounds off numericField to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

Parameters
Name Description
numericField String

Name of field that returns number when evaluated.

decimalPlace Expression

The number of decimal places to round.

Returns
Type Description
Expression

A new Expression representing the round operation.

roundToPrecision(String numericField, int decimalPlace)

public static Expression roundToPrecision(String numericField, int decimalPlace)

Creates an expression that rounds off numericField to decimalPlace decimal places if decimalPlace is positive, rounds off digits to the left of the decimal point if decimalPlace is negative. Rounds away from zero in halfway cases.

Parameters
Name Description
numericField String

Name of field that returns number when evaluated.

decimalPlace int

The number of decimal places to round.

Returns
Type Description
Expression

A new Expression representing the round operation.

split(Expression value, Expression delimiter)

public static Expression split(Expression value, Expression delimiter)

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

Parameters
Name Description
value Expression

The expression representing the string or blob to split.

delimiter Expression

The delimiter to split by.

Returns
Type Description
Expression

A new Expression representing the split string or blob as an array.

split(Expression value, String delimiter)

public static Expression split(Expression value, String delimiter)

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

Parameters
Name Description
value Expression

The expression representing the string or blob to split.

delimiter String

The delimiter to split by.

Returns
Type Description
Expression

A new Expression representing the split string or blob as an array.

split(String fieldName, Expression delimiter)

public static Expression split(String fieldName, Expression delimiter)

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

Parameters
Name Description
fieldName String

The name of the field containing the string or blob to split.

delimiter Expression

The delimiter to split by.

Returns
Type Description
Expression

A new Expression representing the split string or blob as an array.

split(String fieldName, String delimiter)

public static Expression split(String fieldName, String delimiter)

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

Parameters
Name Description
fieldName String

The name of the field containing the string or blob to split.

delimiter String

The delimiter to split by.

Returns
Type Description
Expression

A new Expression representing the split string or blob as an array.

sqrt(Expression numericExpr)

public static Expression sqrt(Expression numericExpr)

Creates an expression that returns the square root of numericExpr.

Parameter
Name Description
numericExpr Expression

An expression that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the square root operation.

sqrt(String numericField)

public static Expression sqrt(String numericField)

Creates an expression that returns the square root of numericField.

Parameter
Name Description
numericField String

Name of field that returns number when evaluated.

Returns
Type Description
Expression

A new Expression representing the numeric result of the square root operation.

startsWith(Expression string, Expression prefix)

public static BooleanExpression startsWith(Expression string, Expression prefix)

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

Parameters
Name Description
string Expression

The expression to check.

prefix Expression

The prefix string expression to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

startsWith(Expression string, String prefix)

public static BooleanExpression startsWith(Expression string, String prefix)

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

Parameters
Name Description
string Expression

The expression to check.

prefix String

The prefix string to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

startsWith(String fieldName, Expression prefix)

public static BooleanExpression startsWith(String fieldName, Expression prefix)

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

Parameters
Name Description
fieldName String

The name of field that contains a string to check.

prefix Expression

The prefix string expression to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

startsWith(String fieldName, String prefix)

public static BooleanExpression startsWith(String fieldName, String prefix)

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

Parameters
Name Description
fieldName String

The name of field that contains a string to check.

prefix String

The prefix string to check for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'starts with' comparison.

stringConcat(Expression firstString, Object[] otherStrings)

public static Expression stringConcat(Expression firstString, Object[] otherStrings)

Creates an expression that concatenates string expressions together.

Parameters
Name Description
firstString Expression

The expression representing the initial string value.

otherStrings Object[]

Optional additional string expressions or string constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated string.

stringConcat(String fieldName, Object[] otherStrings)

public static Expression stringConcat(String fieldName, Object[] otherStrings)

Creates an expression that concatenates string expressions together.

Parameters
Name Description
fieldName String

The field name containing the initial string value.

otherStrings Object[]

Optional additional string expressions or string constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated string.

stringContains(Expression string, Expression substring)

public static BooleanExpression stringContains(Expression string, Expression substring)

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

Parameters
Name Description
string Expression

The expression representing the string to perform the comparison on.

substring Expression

The expression representing the substring to search for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains comparison.

stringContains(Expression string, String substring)

public static BooleanExpression stringContains(Expression string, String substring)

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

Parameters
Name Description
string Expression

The expression representing the string to perform the comparison on.

substring String

The substring to search for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains comparison.

stringContains(String fieldName, Expression substring)

public static BooleanExpression stringContains(String fieldName, Expression substring)

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

Parameters
Name Description
fieldName String

The name of the field to perform the comparison on.

substring Expression

The expression representing the substring to search for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains comparison.

stringContains(String fieldName, String substring)

public static BooleanExpression stringContains(String fieldName, String substring)

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

Parameters
Name Description
fieldName String

The name of the field to perform the comparison on.

substring String

The substring to search for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains comparison.

substring(Expression string, Expression index, Expression length)

public static Expression substring(Expression string, Expression index, Expression length)

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

Parameters
Name Description
string Expression

The expression representing the string to get a substring from.

index Expression

The starting index of the substring.

length Expression

The length of the substring.

Returns
Type Description
Expression

A new Expression representing the substring.

substring(String fieldName, int index, int length)

public static Expression substring(String fieldName, int index, int length)

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

Parameters
Name Description
fieldName String

The name of the field containing the string to get a substring from.

index int

The starting index of the substring.

length int

The length of the substring.

Returns
Type Description
Expression

A new Expression representing the substring.

subtract(Expression minuend, Expression subtrahend)

public static Expression subtract(Expression minuend, Expression subtrahend)

Creates an expression that subtracts two expressions.

Parameters
Name Description
minuend Expression

Numeric expression to subtract from.

subtrahend Expression

Numeric expression to subtract.

Returns
Type Description
Expression

A new Expression representing the subtract operation.

subtract(Expression minuend, Number subtrahend)

public static Expression subtract(Expression minuend, Number subtrahend)

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

Parameters
Name Description
minuend Expression

Numeric expression to subtract from.

subtrahend Number

Constant to subtract.

Returns
Type Description
Expression

A new Expression representing the subtract operation.

subtract(String fieldName, Expression subtrahend)

public static Expression subtract(String fieldName, Expression subtrahend)

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

Parameters
Name Description
fieldName String

Numeric field to subtract from.

subtrahend Expression

Numeric expression to subtract.

Returns
Type Description
Expression

A new Expression representing the subtract operation.

subtract(String fieldName, Number subtrahend)

public static Expression subtract(String fieldName, Number subtrahend)

Creates an expression that subtracts a constant from numeric field.

Parameters
Name Description
fieldName String

Numeric field to subtract from.

subtrahend Number

Constant to subtract.

Returns
Type Description
Expression

A new Expression representing the subtract operation.

timestampAdd(Expression timestamp, Expression unit, Expression amount)

public static Expression timestampAdd(Expression timestamp, Expression unit, Expression amount)

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

Parameters
Name Description
timestamp Expression

The expression representing the timestamp.

unit Expression

The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount Expression

The expression representing the amount of time to add.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampAdd(Expression timestamp, String unit, long amount)

public static Expression timestampAdd(Expression timestamp, String unit, long amount)

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

Parameters
Name Description
timestamp Expression

The expression representing the timestamp.

unit String

The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount long

The amount of time to add.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampAdd(String fieldName, Expression unit, Expression amount)

public static Expression timestampAdd(String fieldName, Expression unit, Expression amount)

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

Parameters
Name Description
fieldName String

The name of the field that contains the timestamp.

unit Expression

The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount Expression

The expression representing the amount of time to add.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampAdd(String fieldName, String unit, long amount)

public static Expression timestampAdd(String fieldName, String unit, long amount)

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

Parameters
Name Description
fieldName String

The name of the field that contains the timestamp.

unit String

The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount long

The amount of time to add.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampSubtract(Expression timestamp, Expression unit, Expression amount)

public static Expression timestampSubtract(Expression timestamp, Expression unit, Expression amount)

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

Parameters
Name Description
timestamp Expression

The expression representing the timestamp.

unit Expression

The expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount Expression

The expression representing the amount of time to subtract.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampSubtract(Expression timestamp, String unit, long amount)

public static Expression timestampSubtract(Expression timestamp, String unit, long amount)

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

Parameters
Name Description
timestamp Expression

The expression representing the timestamp.

unit String

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount long

The amount of time to subtract.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampSubtract(String fieldName, Expression unit, Expression amount)

public static Expression timestampSubtract(String fieldName, Expression unit, Expression amount)

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

Parameters
Name Description
fieldName String

The name of the field that contains the timestamp.

unit Expression

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount Expression

The amount of time to subtract.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampSubtract(String fieldName, String unit, long amount)

public static Expression timestampSubtract(String fieldName, String unit, long amount)

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

Parameters
Name Description
fieldName String

The name of the field that contains the timestamp.

unit String

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount long

The amount of time to subtract.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampToUnixMicros(Expression expr)

public static Expression timestampToUnixMicros(Expression expr)

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

Parameter
Name Description
expr Expression

The expression representing the timestamp.

Returns
Type Description
Expression

A new Expression representing the number of microseconds since epoch.

timestampToUnixMicros(String fieldName)

public static Expression timestampToUnixMicros(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field that contains the timestamp.

Returns
Type Description
Expression

A new Expression representing the number of microseconds since epoch.

timestampToUnixMillis(Expression expr)

public static Expression timestampToUnixMillis(Expression expr)

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

Parameter
Name Description
expr Expression

The expression representing the timestamp.

Returns
Type Description
Expression

A new Expression representing the number of milliseconds since epoch.

timestampToUnixMillis(String fieldName)

public static Expression timestampToUnixMillis(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field that contains the timestamp.

Returns
Type Description
Expression

A new Expression representing the number of milliseconds since epoch.

timestampToUnixSeconds(Expression expr)

public static Expression timestampToUnixSeconds(Expression expr)

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

Parameter
Name Description
expr Expression

The expression representing the timestamp.

Returns
Type Description
Expression

A new Expression representing the number of seconds since epoch.

timestampToUnixSeconds(String fieldName)

public static Expression timestampToUnixSeconds(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field that contains the timestamp.

Returns
Type Description
Expression

A new Expression representing the number of seconds since epoch.

timestampTruncate(Expression timestamp, Expression granularity)

public static Expression timestampTruncate(Expression timestamp, Expression granularity)

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

Parameters
Name Description
timestamp Expression

The timestamp expression.

granularity Expression

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(Expression timestamp, Expression granularity, String timezone)

public static Expression timestampTruncate(Expression timestamp, Expression granularity, String timezone)

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

Parameters
Name Description
timestamp Expression

The timestamp expression.

granularity Expression

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

timezone String

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(Expression timestamp, String granularity)

public static Expression timestampTruncate(Expression timestamp, String granularity)

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

Parameters
Name Description
timestamp Expression

The timestamp expression.

granularity String

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(Expression timestamp, String granularity, String timezone)

public static Expression timestampTruncate(Expression timestamp, String granularity, String timezone)

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

Parameters
Name Description
timestamp Expression

The timestamp expression.

granularity String

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

timezone String

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(String fieldName, Expression granularity)

public static Expression timestampTruncate(String fieldName, Expression granularity)

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

Parameters
Name Description
fieldName String

The name of the field containing the timestamp.

granularity Expression

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(String fieldName, Expression granularity, String timezone)

public static Expression timestampTruncate(String fieldName, Expression granularity, String timezone)

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

Parameters
Name Description
fieldName String

The name of the field containing the timestamp.

granularity Expression

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

timezone String

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(String fieldName, String granularity)

public static Expression timestampTruncate(String fieldName, String granularity)

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

Parameters
Name Description
fieldName String

The name of the field containing the timestamp.

granularity String

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(String fieldName, String granularity, String timezone)

public static Expression timestampTruncate(String fieldName, String granularity, String timezone)

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

Parameters
Name Description
fieldName String

The name of the field containing the timestamp.

granularity String

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

timezone String

The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

toLower(Expression string)

public static Expression toLower(Expression string)

Creates an expression that converts a string expression to lowercase.

Parameter
Name Description
string Expression

The expression representing the string to convert to lowercase.

Returns
Type Description
Expression

A new Expression representing the lowercase string.

toLower(String fieldName)

public static Expression toLower(String fieldName)

Creates an expression that converts a string field to lowercase.

Parameter
Name Description
fieldName String

The name of the field containing the string to convert to lowercase.

Returns
Type Description
Expression

A new Expression representing the lowercase string.

toUpper(Expression string)

public static Expression toUpper(Expression string)

Creates an expression that converts a string expression to uppercase.

Parameter
Name Description
string Expression

The expression representing the string to convert to uppercase.

Returns
Type Description
Expression

A new Expression representing the lowercase string.

toUpper(String fieldName)

public static Expression toUpper(String fieldName)

Creates an expression that converts a string field to uppercase.

Parameter
Name Description
fieldName String

The name of the field containing the string to convert to uppercase.

Returns
Type Description
Expression

A new Expression representing the lowercase string.

trim(Expression string)

public static Expression trim(Expression string)

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

Parameter
Name Description
string Expression

The expression representing the string to trim.

Returns
Type Description
Expression

A new Expression representing the trimmed string.

trim(String fieldName)

public static Expression trim(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field containing the string to trim.

Returns
Type Description
Expression

A new Expression representing the trimmed string.

trimValue(Expression value, Expression characters)

public static Expression trimValue(Expression value, Expression characters)

Creates an expression that removes specified characters from the beginning and end of a string or blob.

Parameters
Name Description
value Expression

The expression representing the string or blob to trim.

characters Expression

The expression representing the characters to remove.

Returns
Type Description
Expression

A new Expression representing the trimmed string or blob.

trimValue(Expression value, String characters)

public static Expression trimValue(Expression value, String characters)

Creates an expression that removes specified characters from the beginning and end of a string or blob.

Parameters
Name Description
value Expression

The expression representing the string or blob to trim.

characters String

The characters to remove.

Returns
Type Description
Expression

A new Expression representing the trimmed string or blob.

trimValue(String fieldName, Expression characters)

public static Expression trimValue(String fieldName, Expression characters)

Creates an expression that removes specified characters from the beginning and end of a string or blob.

Parameters
Name Description
fieldName String

The name of the field containing the string or blob to trim.

characters Expression

The expression representing the characters to remove.

Returns
Type Description
Expression

A new Expression representing the trimmed string or blob.

trimValue(String fieldName, String characters)

public static Expression trimValue(String fieldName, String characters)

Creates an expression that removes specified characters from the beginning and end of a string or blob.

Parameters
Name Description
fieldName String

The name of the field containing the string or blob to trim.

characters String

The characters to remove.

Returns
Type Description
Expression

A new Expression representing the trimmed string or blob.

type(Expression expr)

public static Expression type(Expression expr)

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

Parameter
Name Description
expr Expression

The expression to get the type of.

Returns
Type Description
Expression

A new Expression representing the type operation.

type(String fieldName)

public static Expression type(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field to get the type of.

Returns
Type Description
Expression

A new Expression representing the type operation.

unixMicrosToTimestamp(Expression expr)

public static Expression unixMicrosToTimestamp(Expression expr)

Creates an expression that converts a Unix timestamp in microseconds to a Firestore timestamp.

Parameter
Name Description
expr Expression

The expression representing the Unix timestamp in microseconds.

Returns
Type Description
Expression

A new Expression representing the Firestore timestamp.

unixMicrosToTimestamp(String fieldName)

public static Expression unixMicrosToTimestamp(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field containing the number of microseconds since epoch.

Returns
Type Description
Expression

A new Expression representing the timestamp.

unixMillisToTimestamp(Expression expr)

public static Expression unixMillisToTimestamp(Expression expr)

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

Parameter
Name Description
expr Expression

The expression representing the number of milliseconds since epoch.

Returns
Type Description
Expression

A new Expression representing the timestamp.

unixMillisToTimestamp(String fieldName)

public static Expression unixMillisToTimestamp(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field containing the number of milliseconds since epoch.

Returns
Type Description
Expression

A new Expression representing the timestamp.

unixSecondsToTimestamp(Expression expr)

public static Expression unixSecondsToTimestamp(Expression expr)

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

Parameter
Name Description
expr Expression

The expression representing the number of seconds since epoch.

Returns
Type Description
Expression

A new Expression representing the timestamp.

unixSecondsToTimestamp(String fieldName)

public static Expression unixSecondsToTimestamp(String fieldName)

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

Parameter
Name Description
fieldName String

The name of the field containing the number of seconds since epoch.

Returns
Type Description
Expression

A new Expression representing the timestamp.

vectorLength(Expression vectorExpression)

public static Expression vectorLength(Expression vectorExpression)

Creates an expression that calculates the length of a vector.

Parameter
Name Description
vectorExpression Expression

The expression representing the vector.

Returns
Type Description
Expression

A new Expression representing the length of the vector.

vectorLength(String fieldName)

public static Expression vectorLength(String fieldName)

Creates an expression that calculates the length of a vector.

Parameter
Name Description
fieldName String

The field name of the vector.

Returns
Type Description
Expression

A new Expression representing the length of the vector.

xor(BooleanExpression condition, BooleanExpression[] conditions)

public static BooleanExpression xor(BooleanExpression condition, BooleanExpression[] conditions)

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

Parameters
Name Description
condition BooleanExpression

The first BooleanExpression.

conditions BooleanExpression[]

Additional BooleanExpressions.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the logical 'XOR' operation.

Methods

abs()

public final Expression abs()

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

Returns
Type Description
Expression

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

add(Object other)

public final Expression add(Object other)

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

Parameter
Name Description
other Object

Numeric expression to add.

Returns
Type Description
Expression

A new Expression representing the addition operation.

arrayConcat(Expression[] otherArrays)

public final Expression arrayConcat(Expression[] otherArrays)

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

Parameter
Name Description
otherArrays Expression[]

Optional additional array expressions or array literals to concatenate.

Returns
Type Description
Expression

A new Expression representing the arrayConcat operation.

arrayContains(Object element)

public final BooleanExpression arrayContains(Object element)

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

Parameter
Name Description
element Object

The element to search for in the array.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the arrayContains operation.

arrayContainsAll(Expression arrayExpression)

public final BooleanExpression arrayContainsAll(Expression arrayExpression)

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

Parameter
Name Description
arrayExpression Expression

The elements to check for in the array.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAll(List<Object> values)

public final BooleanExpression arrayContainsAll(List<Object> values)

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

Parameter
Name Description
values List<Object>

The elements to check for in the array.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the arrayContainsAll operation.

arrayContainsAny(Expression arrayExpression)

public final BooleanExpression arrayContainsAny(Expression arrayExpression)

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

Parameter
Name Description
arrayExpression Expression

The elements to check for in the array.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayContainsAny(List<Object> values)

public final BooleanExpression arrayContainsAny(List<Object> values)

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

Parameter
Name Description
values List<Object>

The elements to check for in the array.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the arrayContainsAny operation.

arrayGet(Expression offset)

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

Parameter
Name Description
offset Expression

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

Returns
Type Description
Expression

A new Expression representing the arrayGet operation.

arrayGet(int offset)

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

Parameter
Name Description
offset int

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

Returns
Type Description
Expression

A new Expression representing the arrayOffset operation.

arrayLength()

public final Expression arrayLength()

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

Returns
Type Description
Expression

A new Expression representing the length of the array.

arrayReverse()

public final Expression arrayReverse()

Reverses the order of elements in the array.

Returns
Type Description
Expression

A new Expression representing the arrayReverse operation.

arraySum()

public Expression arraySum()

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

Returns
Type Description
Expression

A new Expression representing the sum of the elements of the array.

as(String alias)

public Selectable as(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.

Parameter
Name Description
alias String

The alias to assign to this expression.

Returns
Type Description
Selectable

A new Selectable (typically an AliasedExpression) that wraps this expression and associates it with the provided alias.

ascending()

public final Ordering ascending()

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

Returns
Type Description
Ordering

A new Ordering object with ascending sort by this expression.

average()

public final AggregateFunction average()

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

Returns
Type Description
AggregateFunction

A new AggregateFunction representing the average aggregation.

byteLength()

public final Expression byteLength()

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

Returns
Type Description
Expression

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

ceil()

public final Expression ceil()

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

Returns
Type Description
Expression

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

charLength()

public final Expression charLength()

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

Returns
Type Description
Expression

A new Expression representing the charLength operation.

collectionId()

public final Expression collectionId()

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

Returns
Type Description
Expression

A new Expression representing the collectionId operation.

concat(Object[] others)

public Expression concat(Object[] others)

Creates an expression that concatenates this expression with other values.

Parameter
Name Description
others Object[]

Optional additional expressions or constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated value.

cosineDistance(Expression vector)

public final Expression cosineDistance(Expression vector)

Calculates the Cosine distance between this and another vector expressions.

Parameter
Name Description
vector Expression

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

Returns
Type Description
Expression

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

cosineDistance(double[] vector)

public final Expression cosineDistance(double[] vector)

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

Parameter
Name Description
vector double[]

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

Returns
Type Description
Expression

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

count()

public final AggregateFunction count()

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

Returns
Type Description
AggregateFunction

A new AggregateFunction representing the count aggregation.

countDistinct()

public final AggregateFunction countDistinct()

Creates an aggregation that counts the number of distinct values of this expression.

Returns
Type Description
AggregateFunction

A new AggregateFunction representing the count distinct aggregation.

descending()

public final Ordering descending()

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

Returns
Type Description
Ordering

A new Ordering object with descending sort by this expression.

divide(Object other)

public final Expression divide(Object other)

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

Parameter
Name Description
other Object

Numeric expression to divide this numeric expression by.

Returns
Type Description
Expression

A new Expression representing the division operation.

documentId()

public final Expression documentId()

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

Returns
Type Description
Expression

A new Expression representing the documentId operation.

dotProduct(Expression vector)

public final Expression dotProduct(Expression vector)

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

Parameter
Name Description
vector Expression

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

Returns
Type Description
Expression

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

dotProduct(double[] vector)

public final Expression dotProduct(double[] vector)

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

Parameter
Name Description
vector double[]

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

Returns
Type Description
Expression

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

endsWith(Object suffix)

public final BooleanExpression endsWith(Object suffix)

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

Parameter
Name Description
suffix Object

The suffix string expression to check for.

Returns
Type Description
BooleanExpression

A new Expression representing the 'ends with' comparison.

equal(Object other)

public final BooleanExpression equal(Object other)

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

Parameter
Name Description
other Object

The value to compare to.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the equality comparison.

equalAny(List<Object> other)

public final BooleanExpression equalAny(List<Object> other)

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

Parameter
Name Description
other List<Object>

The values to check against.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'IN' comparison.

euclideanDistance(Expression vector)

public final Expression euclideanDistance(Expression vector)

Calculates the Euclidean distance between this and another vector expression.

Parameter
Name Description
vector Expression

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

Returns
Type Description
Expression

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

euclideanDistance(double[] vector)

public final Expression euclideanDistance(double[] vector)

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

Parameter
Name Description
vector double[]

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

Returns
Type Description
Expression

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

exists()

public final BooleanExpression exists()

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

Returns
Type Description
BooleanExpression

A new Expression representing the exists check.

exp()

public final Expression exp()

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

Returns
Type Description
Expression

A new Expression representing the numeric result of the exponentiation.

floor()

public final Expression floor()

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

Returns
Type Description
Expression

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

greaterThan(Object other)

public final BooleanExpression greaterThan(Object other)

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

Parameter
Name Description
other Object

The value to compare to.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than comparison.

greaterThanOrEqual(Object other)

public final BooleanExpression greaterThanOrEqual(Object other)

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

Parameter
Name Description
other Object

The value to compare to.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the greater than or equal to comparison.

ifAbsent(Object elseValue)

public Expression ifAbsent(Object elseValue)

Creates an expression that returns a default value if this expression evaluates to an absent value.

Parameter
Name Description
elseValue Object

The default value.

Returns
Type Description
Expression

A new Expression representing the ifAbsent operation.

ifError(Expression catchExpr)

public final Expression ifError(Expression catchExpr)

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

Parameter
Name Description
catchExpr Expression

The catch expression that will be evaluated and returned if the this expression produces an error.

Returns
Type Description
Expression

A new Expression representing the ifError operation.

ifError(Object catchValue)

public final Expression ifError(Object catchValue)

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

Parameter
Name Description
catchValue Object

The value that will be returned if this expression produces an error.

Returns
Type Description
Expression

A new Expression representing the ifError operation.

isAbsent()

public final BooleanExpression isAbsent()

Creates an expression that returns true if yhe result of this expression is absent. Otherwise, returns false even if the value is null.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isAbsent operation.

isError()

public final BooleanExpression isError()

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

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isError check.

isNaN()

public final BooleanExpression isNaN()

Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number).

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isNan operation.

isNotNaN()

public final BooleanExpression isNotNaN()

Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isNotNan operation.

isNotNull()

public final BooleanExpression isNotNull()

Creates an expression that checks if tbe result of this expression is not null.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isNotNull operation.

isNull()

public final BooleanExpression isNull()

Creates an expression that checks if tbe result of this expression is null.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the isNull operation.

join(Expression delimiter)

public Expression join(Expression delimiter)

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

Parameter
Name Description
delimiter Expression

The delimiter to use.

Returns
Type Description
Expression

A new Expression representing the join operation.

join(String delimiter)

public Expression join(String delimiter)

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

Parameter
Name Description
delimiter String

The delimiter to use.

Returns
Type Description
Expression

A new Expression representing the join operation.

length()

public final Expression length()

Creates an expression that calculates the length of the expression if it is a string, array, map, or Blob.

Returns
Type Description
Expression

A new Expression representing the length of the expression.

lessThan(Object other)

public final BooleanExpression lessThan(Object other)

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

Parameter
Name Description
other Object

The value to compare to.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than comparison.

lessThanOrEqual(Object other)

public final BooleanExpression lessThanOrEqual(Object other)

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

Parameter
Name Description
other Object

The value to compare to.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the less than or equal to comparison.

like(Object pattern)

public final BooleanExpression like(Object pattern)

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

Parameter
Name Description
pattern Object

The pattern to search for. You can use "%" as a wildcard character.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the like operation.

ln()

public final Expression ln()

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

Returns
Type Description
Expression

A new Expression representing the numeric result of the natural logarithm.

log10()

public Expression log10()

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

Returns
Type Description
Expression

A new Expression representing the numeric result of the base 10 logarithm.

logicalMaximum(Object[] others)

public final Expression logicalMaximum(Object[] others)

Creates an expression that returns the largest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

Parameter
Name Description
others Object[]

Optional additional expressions or literals.

Returns
Type Description
Expression

A new Expression representing the logical maximum operation.

logicalMinimum(Object[] others)

public final Expression logicalMinimum(Object[] others)

Creates an expression that returns the smallest value between multiple input expressions or literal values. Based on Firestore's value type ordering.

Parameter
Name Description
others Object[]

Optional additional expressions or literals.

Returns
Type Description
Expression

A new Expression representing the logical minimum operation.

mapGet(Object key)

public final Expression mapGet(Object key)

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

Parameter
Name Description
key Object

The key to access in the map.

Returns
Type Description
Expression

A new Expression representing the value associated with the given key in the map.

mapMerge(Expression secondMap, Expression[] otherMaps)

public final Expression mapMerge(Expression secondMap, Expression[] otherMaps)

Creates an expression that merges multiple maps into a single map. If multiple maps have the same key, the later value is used.

Parameters
Name Description
secondMap Expression

Map expression that will be merged.

otherMaps Expression[]

Additional maps to merge.

Returns
Type Description
Expression

A new Expression representing the mapMerge operation.

mapRemove(Expression key)

public final Expression mapRemove(Expression key)

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

Parameter
Name Description
key Expression

The name of the key to remove from this map expression.

Returns
Type Description
Expression

A new Expression that evaluates to a modified map.

mapRemove(String key)

public final Expression mapRemove(String key)

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

Parameter
Name Description
key String

The name of the key to remove from this map expression.

Returns
Type Description
Expression

A new Expression that evaluates to a modified map.

maximum()

public final AggregateFunction maximum()

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

Returns
Type Description
AggregateFunction

A new AggregateFunction representing the maximum aggregation.

minimum()

public final AggregateFunction minimum()

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

Returns
Type Description
AggregateFunction

A new AggregateFunction representing the minimum aggregation.

mod(Object other)

public final Expression mod(Object other)

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

Parameter
Name Description
other Object

The numeric expression to divide this expression by.

Returns
Type Description
Expression

A new Expression representing the modulo operation.

multiply(Object other)

public final Expression multiply(Object other)

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

Parameter
Name Description
other Object

Numeric expression to multiply.

Returns
Type Description
Expression

A new Expression representing the multiplication operation.

notEqual(Object other)

public final BooleanExpression notEqual(Object other)

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

Parameter
Name Description
other Object

The value to compare to.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the inequality comparison.

notEqualAny(List<Object> other)

public final BooleanExpression notEqualAny(List<Object> other)

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

Parameter
Name Description
other List<Object>

The values to check against.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the 'NOT IN' comparison.

pow(Expression exponent)

public final Expression pow(Expression exponent)

Creates an expression that returns this numeric expression raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

Parameter
Name Description
exponent Expression

The numeric power to raise this numeric expression.

Returns
Type Description
Expression

A new Expression representing a numeric result from raising this numeric expression to the power of exponent.

pow(Number exponent)

public final Expression pow(Number exponent)

Creates an expression that returns this numeric expression raised to the power of the exponent. Returns infinity on overflow and zero on underflow.

Parameter
Name Description
exponent Number

The numeric power to raise this numeric expression.

Returns
Type Description
Expression

A new Expression representing a numeric result from raising this numeric expression to the power of exponent.

regexContains(Object pattern)

public final BooleanExpression regexContains(Object pattern)

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

Parameter
Name Description
pattern Object

The regular expression to use for the search.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains regular expression comparison.

regexMatch(Object pattern)

public final BooleanExpression regexMatch(Object pattern)

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

Parameter
Name Description
pattern Object

The regular expression to use for the match.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the regular expression match comparison.

reverse()

public final Expression reverse()

Creates an expression that reverses this expression, which must be a string, blob, or array.

Returns
Type Description
Expression

A new Expression representing the reversed value.

round()

public final Expression round()

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

Rounds away from zero in halfway cases.

Returns
Type Description
Expression

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

roundToPrecision(Expression decimalPlace)

public final Expression roundToPrecision(Expression 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. Rounds away from zero in halfway cases.

Parameter
Name Description
decimalPlace Expression

The number of decimal places to round.

Returns
Type Description
Expression

A new Expression representing the round operation.

roundToPrecision(int decimalPlace)

public final 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. Rounds away from zero in halfway cases.

Parameter
Name Description
decimalPlace int

The number of decimal places to round.

Returns
Type Description
Expression

A new Expression representing the round operation.

split(Expression delimiter)

public Expression split(Expression delimiter)

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

Parameter
Name Description
delimiter Expression

The delimiter to split by.

Returns
Type Description
Expression

A new Expression representing the split string or blob as an array.

split(String delimiter)

public Expression split(String delimiter)

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

Parameter
Name Description
delimiter String

The delimiter to split by.

Returns
Type Description
Expression

A new Expression representing the split string or blob as an array.

sqrt()

public final Expression sqrt()

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

Returns
Type Description
Expression

A new Expression representing the numeric result of the square root operation.

startsWith(Object prefix)

public final BooleanExpression startsWith(Object prefix)

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

Parameter
Name Description
prefix Object

The prefix string expression to check for.

Returns
Type Description
BooleanExpression

A new Expression representing the the 'starts with' comparison.

stringConcat(Expression[] others)

public final Expression stringConcat(Expression[] others)

Creates an expression that concatenates string expressions together.

Parameter
Name Description
others Expression[]

The string expressions or string constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated string.

stringConcat(String[] others)

public final Expression stringConcat(String[] others)

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

Parameter
Name Description
others String[]

The string expressions or string constants to concatenate.

Returns
Type Description
Expression

A new Expression representing the concatenated string.

stringContains(Object substring)

public final BooleanExpression stringContains(Object substring)

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

Parameter
Name Description
substring Object

The expression representing the substring to search for.

Returns
Type Description
BooleanExpression

A new BooleanExpression representing the contains comparison.

substring(Object index, Object length)

public final Expression substring(Object index, Object length)

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

Parameters
Name Description
index Object

The starting index of the substring.

length Object

The length of the substring.

Returns
Type Description
Expression

A new Expression representing the substring.

subtract(Object other)

public final Expression subtract(Object other)

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

Parameter
Name Description
other Object

Constant to subtract.

Returns
Type Description
Expression

A new Expression representing the subtract operation.

sum()

public final AggregateFunction sum()

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

Returns
Type Description
AggregateFunction

A new AggregateFunction representing the sum aggregation.

timestampAdd(Expression unit, Expression amount)

public final Expression timestampAdd(Expression unit, Expression amount)

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

Parameters
Name Description
unit Expression

The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount Expression

The expression representing the amount of time to add.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampAdd(String unit, long amount)

public final Expression timestampAdd(String unit, long amount)

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

Parameters
Name Description
unit String

The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount long

The amount of time to add.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampSubtract(Expression unit, Expression amount)

public final Expression timestampSubtract(Expression unit, Expression amount)

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

Parameters
Name Description
unit Expression

The expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount Expression

The expression representing the amount of time to subtract.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampSubtract(String unit, long amount)

public final Expression timestampSubtract(String unit, long amount)

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

Parameters
Name Description
unit String

The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".

amount long

The amount of time to subtract.

Returns
Type Description
Expression

A new Expression representing the resulting timestamp.

timestampToUnixMicros()

public final Expression timestampToUnixMicros()

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

Returns
Type Description
Expression

A new Expression representing the number of microseconds since epoch.

timestampToUnixMillis()

public final Expression timestampToUnixMillis()

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

Returns
Type Description
Expression

A new Expression representing the number of milliseconds since epoch.

timestampToUnixSeconds()

public final Expression timestampToUnixSeconds()

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

Returns
Type Description
Expression

A new Expression representing the number of seconds since epoch.

timestampTruncate(Expression granularity)

public final Expression timestampTruncate(Expression granularity)

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

Parameter
Name Description
granularity Expression

The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

timestampTruncate(String granularity)

public final Expression timestampTruncate(String granularity)

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

Parameter
Name Description
granularity String

The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".

Returns
Type Description
Expression

A new Expression representing the truncated timestamp.

toLower()

public final Expression toLower()

Creates an expression that converts this string expression to lowercase.

Returns
Type Description
Expression

A new Expression representing the lowercase string.

toUpper()

public final Expression toUpper()

Creates an expression that converts this string expression to uppercase.

Returns
Type Description
Expression

A new Expression representing the lowercase string.

trim()

public final Expression trim()

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

Returns
Type Description
Expression

A new Expression representing the trimmed string.

trimValue(Expression characters)

public Expression trimValue(Expression characters)

Creates an expression that removes specified characters from the beginning and end of this string or blob expression.

Parameter
Name Description
characters Expression

The expression representing the characters to remove.

Returns
Type Description
Expression

A new Expression representing the trimmed string or blob.

trimValue(String characters)

public Expression trimValue(String characters)

Creates an expression that removes specified characters from the beginning and end of this string or blob expression.

Parameter
Name Description
characters String

The characters to remove.

Returns
Type Description
Expression

A new Expression representing the trimmed string or blob.

type()

public final Expression type()

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

Returns
Type Description
Expression

A new Expression representing the type operation.

unixMicrosToTimestamp()

public final Expression unixMicrosToTimestamp()

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.

Returns
Type Description
Expression

A new Expression representing the timestamp.

unixMillisToTimestamp()

public final Expression unixMillisToTimestamp()

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.

Returns
Type Description
Expression

A new Expression representing the timestamp.

unixSecondsToTimestamp()

public final Expression unixSecondsToTimestamp()

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.

Returns
Type Description
Expression

A new Expression representing the timestamp.

vectorLength()

public final Expression vectorLength()

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

Returns
Type Description
Expression

A new Expression representing the length (dimension) of the vector.