public abstract class ExpressionRepresents 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.
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 |
ExpressionAn 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 |
StringName 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 |
ExpressionNumeric expression to add. |
second |
ExpressionNumeric 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 |
ExpressionNumeric expression to add. |
second |
NumberConstant 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 |
StringNumeric field to add. |
second |
ExpressionNumeric 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 |
StringNumeric field to add. |
second |
NumberConstant 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 |
BooleanExpressionThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe expression representing the array. |
element |
ExpressionThe 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 |
ExpressionThe expression representing the array. |
element |
ObjectThe 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 |
StringThe field name of the array. |
element |
ExpressionThe 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 |
StringThe field name of the array. |
element |
ObjectThe 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 |
ExpressionThe expression representing the array. |
arrayExpression |
ExpressionThe 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 |
ExpressionThe 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 |
StringThe field name of the array. |
arrayExpression |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe expression representing the array. |
arrayExpression |
ExpressionThe 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 |
ExpressionThe 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 |
StringThe field name of the array. |
arrayExpression |
ExpressionThe 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 |
StringThe 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. |
arrayFilter(Expression array, String alias, BooleanExpression filter)
public static Expression arrayFilter(Expression array, String alias, BooleanExpression filter)Filters an array expression based on a predicate.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to filter. |
alias |
StringThe alias for the current element in the filter expression. |
filter |
BooleanExpressionThe predicate boolean expression used to filter the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the filtered array. |
arrayFilter(String arrayFieldName, String alias, BooleanExpression filter)
public static Expression arrayFilter(String arrayFieldName, String alias, BooleanExpression filter)Filters an array field based on a predicate.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to filter. |
alias |
StringThe alias for the current element in the filter expression. |
filter |
BooleanExpressionThe predicate boolean expression used to filter the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the filtered array. |
arrayFirst(Expression array)
public static Expression arrayFirst(Expression array)Creates an expression that returns the first element of an array.
| Parameter | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first element of the array. |
arrayFirst(String arrayFieldName)
public static Expression arrayFirst(String arrayFieldName)Creates an expression that returns the first element of an array.
| Parameter | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first element of the array. |
arrayFirstN(Expression array, Expression n)
public static Expression arrayFirstN(Expression array, Expression n)Creates an expression that returns the first n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first n elements of the array. |
arrayFirstN(Expression array, int n)
public static Expression arrayFirstN(Expression array, int n)Creates an expression that returns the first n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first n elements of the array. |
arrayFirstN(String arrayFieldName, Expression n)
public static Expression arrayFirstN(String arrayFieldName, Expression n)Creates an expression that returns the first n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first n elements of the array. |
arrayFirstN(String arrayFieldName, int n)
public static Expression arrayFirstN(String arrayFieldName, int n)Creates an expression that returns the first n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first n elements of the array. |
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 |
ExpressionThe expression representing the array. |
offset |
ExpressionThe 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 |
ExpressionThe expression representing the array. |
offset |
intThe 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 |
StringThe field name of the array. |
offset |
ExpressionThe 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 |
StringThe field name of the array. |
offset |
intThe index of the element to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the element at the specified index. |
arrayIndexOf(Expression array, Expression value)
public static Expression arrayIndexOf(Expression array, Expression value)Creates an expression that returns the index of the first occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
arrayIndexOf(Expression array, Object value)
public static Expression arrayIndexOf(Expression array, Object value)Creates an expression that returns the index of the first occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
arrayIndexOf(String arrayFieldName, Expression value)
public static Expression arrayIndexOf(String arrayFieldName, Expression value)Creates an expression that returns the index of the first occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
arrayIndexOf(String arrayFieldName, Object value)
public static Expression arrayIndexOf(String arrayFieldName, Object value)Creates an expression that returns the index of the first occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
arrayIndexOfAll(Expression array, Expression value)
public static Expression arrayIndexOfAll(Expression array, Expression value)Creates an expression that returns all indices of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the indices. |
arrayIndexOfAll(Expression array, Object value)
public static Expression arrayIndexOfAll(Expression array, Object value)Creates an expression that returns all indices of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the indices. |
arrayIndexOfAll(String arrayFieldName, Expression value)
public static Expression arrayIndexOfAll(String arrayFieldName, Expression value)Creates an expression that returns all indices of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the indices. |
arrayIndexOfAll(String arrayFieldName, Object value)
public static Expression arrayIndexOfAll(String arrayFieldName, Object value)Creates an expression that returns all indices of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the indices. |
arrayLast(Expression array)
public static Expression arrayLast(Expression array)Creates an expression that returns the last element of an array.
| Parameter | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last element of the array. |
arrayLast(String arrayFieldName)
public static Expression arrayLast(String arrayFieldName)Creates an expression that returns the last element of an array.
| Parameter | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last element of the array. |
arrayLastIndexOf(Expression array, Expression value)
public static Expression arrayLastIndexOf(Expression array, Expression value)Creates an expression that returns the index of the last occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last index. |
arrayLastIndexOf(Expression array, Object value)
public static Expression arrayLastIndexOf(Expression array, Object value)Creates an expression that returns the index of the last occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last index. |
arrayLastIndexOf(String arrayFieldName, Expression value)
public static Expression arrayLastIndexOf(String arrayFieldName, Expression value)Creates an expression that returns the index of the last occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last index. |
arrayLastIndexOf(String arrayFieldName, Object value)
public static Expression arrayLastIndexOf(String arrayFieldName, Object value)Creates an expression that returns the index of the last occurrence of a value in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last index. |
arrayLastN(Expression array, Expression n)
public static Expression arrayLastN(Expression array, Expression n)Creates an expression that returns the last n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last n elements of the array. |
arrayLastN(Expression array, int n)
public static Expression arrayLastN(Expression array, int n)Creates an expression that returns the last n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last n elements of the array. |
arrayLastN(String arrayFieldName, Expression n)
public static Expression arrayLastN(String arrayFieldName, Expression n)Creates an expression that returns the last n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last n elements of the array. |
arrayLastN(String arrayFieldName, int n)
public static Expression arrayLastN(String arrayFieldName, int n)Creates an expression that returns the last n elements of an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last n elements of the array. |
arrayLength(Expression array)
public static Expression arrayLength(Expression array)Creates an expression that returns the length of an array.
| Parameter | |
|---|---|
| Name | Description |
array |
ExpressionThe 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 |
StringThe field name of the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the length of the array. |
arrayMaximum(Expression array)
public static Expression arrayMaximum(Expression array)Creates an expression that returns the maximum value of an array.
| Parameter | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the maximum value of the array. |
arrayMaximum(String arrayFieldName)
public static Expression arrayMaximum(String arrayFieldName)Creates an expression that returns the maximum value of an array.
| Parameter | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the maximum value of the array. |
arrayMaximumN(Expression array, Expression n)
public static Expression arrayMaximumN(Expression array, Expression n)Creates an expression that returns the n maximum values of an array.
Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n maximum values of the array. |
arrayMaximumN(Expression array, int n)
public static Expression arrayMaximumN(Expression array, int n)Creates an expression that returns the n maximum values of an array.
Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n maximum values of the array. |
arrayMaximumN(String arrayFieldName, Expression n)
public static Expression arrayMaximumN(String arrayFieldName, Expression n)Creates an expression that returns the n maximum values of an array.
Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n maximum values of the array. |
arrayMaximumN(String arrayFieldName, int n)
public static Expression arrayMaximumN(String arrayFieldName, int n)Creates an expression that returns the n maximum values of an array.
Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n maximum values of the array. |
arrayMinimum(Expression array)
public static Expression arrayMinimum(Expression array)Creates an expression that returns the minimum value of an array.
| Parameter | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the minimum value of the array. |
arrayMinimum(String arrayFieldName)
public static Expression arrayMinimum(String arrayFieldName)Creates an expression that returns the minimum value of an array.
| Parameter | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the minimum value of the array. |
arrayMinimumN(Expression array, Expression n)
public static Expression arrayMinimumN(Expression array, Expression n)Creates an expression that returns the n minimum values of an array.
Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n minimum values of the array. |
arrayMinimumN(Expression array, int n)
public static Expression arrayMinimumN(Expression array, int n)Creates an expression that returns the n minimum values of an array.
Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n minimum values of the array. |
arrayMinimumN(String arrayFieldName, Expression n)
public static Expression arrayMinimumN(String arrayFieldName, Expression n)Creates an expression that returns the n minimum values of an array.
Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n minimum values of the array. |
arrayMinimumN(String arrayFieldName, int n)
public static Expression arrayMinimumN(String arrayFieldName, int n)Creates an expression that returns the n minimum values of an array.
Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array. |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n minimum values of the array. |
arrayReverse(Expression array)
public static Expression arrayReverse(Expression array)Creates an expression that reverses an array.
| Parameter | |
|---|---|
| Name | Description |
array |
ExpressionThe 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 |
StringThe field name of the array to reverse. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the reversed array. |
arraySlice(Expression array, Expression offset, Expression length)
public static Expression arraySlice(Expression array, Expression offset, Expression length)Creates an expression that returns a slice of an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to slice. |
offset |
ExpressionThe starting index. |
length |
ExpressionThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySlice(Expression array, int offset, int length)
public static Expression arraySlice(Expression array, int offset, int length)Creates an expression that returns a slice of an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to slice. |
offset |
intThe starting index. |
length |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySlice(String arrayFieldName, Expression offset, Expression length)
public static Expression arraySlice(String arrayFieldName, Expression offset, Expression length)Creates an expression that returns a slice of an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to slice. |
offset |
ExpressionThe starting index. |
length |
ExpressionThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySlice(String arrayFieldName, int offset, int length)
public static Expression arraySlice(String arrayFieldName, int offset, int length)Creates an expression that returns a slice of an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to slice. |
offset |
intThe starting index. |
length |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySliceToEnd(Expression array, Expression offset)
public static Expression arraySliceToEnd(Expression array, Expression offset)Creates an expression that returns a slice of an array to its end.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to slice. |
offset |
ExpressionThe expression representing the starting index. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySliceToEnd(Expression array, int offset)
public static Expression arraySliceToEnd(Expression array, int offset)Creates an expression that returns a slice of an array to its end.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to slice. |
offset |
intThe starting index. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySliceToEnd(String arrayFieldName, Expression offset)
public static Expression arraySliceToEnd(String arrayFieldName, Expression offset)Creates an expression that returns a slice of an array to its end.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to slice. |
offset |
ExpressionThe expression representing the starting index. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySliceToEnd(String arrayFieldName, int offset)
public static Expression arraySliceToEnd(String arrayFieldName, int offset)Creates an expression that returns a slice of an array to its end.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to slice. |
offset |
intThe starting index. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
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 |
ExpressionThe 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 |
StringThe field name of the array. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the sum of the elements of the array. |
arrayTransform(Expression array, String elementAlias, Expression transform)
public static Expression arrayTransform(Expression array, String elementAlias, Expression transform)Creates an expression that applies a provided transformation to each element in an array.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to transform. |
elementAlias |
StringThe alias for the current element in the transform expression. |
transform |
ExpressionThe expression used to transform the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the transformed array. |
arrayTransform(String arrayFieldName, String elementAlias, Expression transform)
public static Expression arrayTransform(String arrayFieldName, String elementAlias, Expression transform)Creates an expression that applies a provided transformation to each element in an array.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to transform. |
elementAlias |
StringThe alias for the current element in the transform expression. |
transform |
ExpressionThe expression used to transform the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the transformed array. |
arrayTransformWithIndex(Expression array, String elementAlias, String indexAlias, Expression transform)
public static Expression arrayTransformWithIndex(Expression array, String elementAlias, String indexAlias, Expression transform)Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression.
| Parameters | |
|---|---|
| Name | Description |
array |
ExpressionThe expression representing the array to transform. |
elementAlias |
StringThe alias for the current element in the transform expression. |
indexAlias |
StringThe alias for the current index. |
transform |
ExpressionThe expression used to transform the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the transformed array. |
arrayTransformWithIndex(String arrayFieldName, String elementAlias, String indexAlias, Expression transform)
public static Expression arrayTransformWithIndex(String arrayFieldName, String elementAlias, String indexAlias, Expression transform)Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression.
| Parameters | |
|---|---|
| Name | Description |
arrayFieldName |
StringThe field name of the array to transform. |
elementAlias |
StringThe alias for the current element in the transform expression. |
indexAlias |
StringThe alias for the current index. |
transform |
ExpressionThe expression used to transform the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the transformed 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionAn 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 |
StringName 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 |
ExpressionThe 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 |
StringThe name of the field containing the string. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the charLength operation. |
coalesce(Expression expression, Object replacement, Object[] others)
public static Expression coalesce(Expression expression, Object replacement, Object[] others)Returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
| Parameters | |
|---|---|
| Name | Description |
expression |
ExpressionThe first expression to check for null. |
replacement |
ObjectThe fallback expression or value if the first one is null. |
others |
Object[]Optional additional expressions to check if previous ones are null. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the coalesce operation. |
coalesce(String firstFieldName, Object replacement, Object[] others)
public static Expression coalesce(String firstFieldName, Object replacement, Object[] others)Returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
| Parameters | |
|---|---|
| Name | Description |
firstFieldName |
StringThe name of the first field to check for null. |
replacement |
ObjectThe fallback expression or value if the first one is null. |
others |
Object[]Optional additional expressions to check if previous ones are null. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the coalesce 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 |
ExpressionAn 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
BooleanExpressionThe condition to evaluate. |
thenExpr |
ExpressionThe expression to evaluate if the condition is true. |
elseExpr |
ExpressionThe 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 |
BooleanExpressionThe condition to evaluate. |
thenValue |
ObjectValue if the condition is true. |
elseValue |
ObjectValue 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.TimestampThe 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 |
BlobThe 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 |
DocumentReferenceThe 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 |
GeoPointThe 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 |
VectorValueThe 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 |
BooleanThe 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 |
NumberThe 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 |
StringThe 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 |
DateThe 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 |
ExpressionThe first vector. |
vector2 |
ExpressionThe 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 |
ExpressionThe 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 |
StringThe field name of the first vector. |
vector |
ExpressionThe 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 |
StringThe field name of the first vector. |
vector |
double[]The second vector. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the cosine distance. |
currentDocument()
public static Expression currentDocument()Creates an expression that represents the current document being processed.
This expression is useful when you need to access the entire document as a map, or pass the document itself to a function or subquery.
Example:
// Define the current document as a variable "doc"
firestore.pipeline().collection("books")
.define(currentDocument().as("doc"))
// Access a field from the defined document variable
.select(variable("doc").getField("title"));
| Returns | |
|---|---|
| Type | Description |
Expression |
An Expression representing the current document. |
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 |
ExpressionThe numeric expression to be divided. |
divisor |
ExpressionThe 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 |
ExpressionThe numeric expression to be divided. |
divisor |
NumberThe 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 |
StringThe numeric field name to be divided. |
divisor |
ExpressionThe 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 |
StringThe numeric field name to be divided. |
divisor |
NumberThe 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 |
DocumentReferenceThe 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 |
ExpressionAn 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 |
StringThe string representation of the document path. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the documentId operation. |
documentMatches(String rquery)
public static BooleanExpression documentMatches(String rquery)Perform a full-text search on all indexed search fields in the document.
This Expression can only be used within a Search stage.
Example:
db.pipeline().collection("restaurants").search(Search.withQuery(documentMatches("waffles OR pancakes")))
| Parameter | |
|---|---|
| Name | Description |
rquery |
StringDefine the search query using the search domain-specific language (DSL). |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the documentMatches 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 |
ExpressionThe first vector. |
vector2 |
ExpressionThe 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 |
ExpressionThe 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 |
StringThe field name of the first vector. |
vector |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe expression to check. |
suffix |
ExpressionThe 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 |
ExpressionThe expression to check. |
suffix |
StringThe 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 |
StringThe name of field that contains a string to check. |
suffix |
ExpressionThe 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 |
StringThe name of field that contains a string to check. |
suffix |
StringThe 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 |
ExpressionThe first expression. |
right |
ExpressionThe 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 |
ExpressionThe expression. |
right |
ObjectThe 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 |
StringThe field name. |
right |
ExpressionThe 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 |
StringThe field name. |
right |
ObjectThe 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 |
ExpressionThe expression whose results to compare. |
arrayExpression |
ExpressionAn 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 |
ExpressionThe 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 |
StringThe field to compare. |
arrayExpression |
ExpressionAn 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 |
StringThe 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 |
ExpressionThe first vector. |
vector2 |
ExpressionThe 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 |
ExpressionThe 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 |
StringThe field name of the first vector. |
vector |
ExpressionThe 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 |
StringThe 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 |
ExpressionAn 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 |
StringThe 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 |
ExpressionAn 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 |
StringName 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 |
FieldPathThe 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 |
StringThe 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 |
ExpressionAn 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 |
StringName of field that returns number when evaluated. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing an integer result from the floor operation. |
geoDistance(Field field, GeoPoint location)
public static Expression geoDistance(Field field, GeoPoint location)Evaluates to the distance in meters between the location in the specified field and the query location.
This Expression can only be used within a Search stage.
Example:
db.pipeline().collection("restaurants").search(
Search.withQuery("waffles").withSort(geoDistance(field("location"), new GeoPoint(37.0, -122.0)).ascending())
)
| Parameters | |
|---|---|
| Name | Description |
field |
FieldSpecifies the field in the document which contains the first GeoPoint for distance computation. |
location |
GeoPointCompute distance to this GeoPoint. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the geoDistance operation. |
geoDistance(String fieldName, GeoPoint location)
public static Expression geoDistance(String fieldName, GeoPoint location)Evaluates to the distance in meters between the location in the specified field and the query location.
This Expression can only be used within a Search stage.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringSpecifies the field in the document which contains the first GeoPoint for distance computation. |
location |
GeoPointCompute distance to this GeoPoint. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the geoDistance operation. |
getField(Expression expression, Expression keyExpression)
public static Expression getField(Expression expression, Expression keyExpression)Accesses a field/property of the expression using the provided keyExpression.
| Parameters | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression evaluating to a Map or Document. |
keyExpression |
ExpressionThe expression evaluating to the key. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the value of the field. |
getField(Expression expression, String key)
public static Expression getField(Expression expression, String key)Accesses a field/property of the expression that evaluates to a Map or Document.
| Parameters | |
|---|---|
| Name | Description |
expression |
ExpressionThe expression evaluating to a map/document. |
key |
StringThe key of the field to access. |
| Returns | |
|---|---|
| Type | Description |
Expression |
An Expression representing the value of the field. |
getField(String fieldName, Expression keyExpression)
public static Expression getField(String fieldName, Expression keyExpression)Accesses a field/property of a document field using the provided keyExpression.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe field name of the map or document field. |
keyExpression |
ExpressionThe expression evaluating to the key. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the value of the field. |
getField(String fieldName, String key)
public static Expression getField(String fieldName, String key)Accesses a field/property of a document field using the provided key.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe field name of the map or document field. |
key |
StringThe key of the field to access. |
| Returns | |
|---|---|
| Type | Description |
Expression |
An Expression representing the value of the field. |
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 |
ExpressionThe first expression. |
right |
ExpressionThe 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 |
ExpressionThe expression. |
right |
ObjectThe 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 |
StringThe field name. |
right |
ExpressionThe 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 |
StringThe field name. |
right |
ObjectThe 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 |
ExpressionThe first expression. |
right |
ExpressionThe 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 |
ExpressionThe expression. |
right |
ObjectThe 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 |
StringThe field name. |
right |
ExpressionThe 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 |
StringThe field name. |
right |
ObjectThe 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 |
ExpressionThe expression to check. |
elseExpr |
ExpressionThe 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 |
ExpressionThe expression to check. |
elseValue |
ObjectThe 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 |
StringThe field to check. |
elseExpr |
ExpressionThe 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 |
StringThe field to check. |
elseValue |
ObjectThe 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 |
BooleanExpressionThe try boolean expression. |
catchExpr |
BooleanExpressionThe catch boolean expression that will be evaluated and returned if the |
| 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 |
ExpressionThe try expression. |
catchExpr |
ExpressionThe catch expression that will be evaluated and returned if the |
| 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 |
ExpressionThe try expression. |
catchValue |
ObjectThe value that will be returned if the |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifError operation. |
ifNull(Expression ifExpr, Expression elseExpression)
public static Expression ifNull(Expression ifExpr, Expression elseExpression)Creates an expression that returns a default value if an expression evaluates to null.
Note: This function provides a fallback for both absent and explicit null values. In contrast, ifAbsent only triggers for missing fields.
| Parameters | |
|---|---|
| Name | Description |
ifExpr |
ExpressionThe expression to check. |
elseExpression |
ExpressionThe default expression that will be evaluated and returned. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifNull operation. |
ifNull(Expression ifExpr, Object elseValue)
public static Expression ifNull(Expression ifExpr, Object elseValue)Creates an expression that returns a default value if an expression evaluates to null.
Note: This function provides a fallback for both absent and explicit null values. In contrast, ifAbsent only triggers for missing fields.
| Parameters | |
|---|---|
| Name | Description |
ifExpr |
ExpressionThe expression to check. |
elseValue |
ObjectThe default value that will be returned. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifNull operation. |
ifNull(String ifFieldName, Expression elseExpression)
public static Expression ifNull(String ifFieldName, Expression elseExpression)Creates an expression that returns a default value if a field is null.
Note: This function provides a fallback for both absent and explicit null values. In contrast, ifAbsent only triggers for missing fields.
| Parameters | |
|---|---|
| Name | Description |
ifFieldName |
StringThe field to check. |
elseExpression |
ExpressionThe default expression that will be evaluated and returned. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifNull operation. |
ifNull(String ifFieldName, Object elseValue)
public static Expression ifNull(String ifFieldName, Object elseValue)Creates an expression that returns a default value if a field is null.
Note: This function provides a fallback for both absent and explicit null values. In contrast, ifAbsent only triggers for missing fields.
| Parameters | |
|---|---|
| Name | Description |
ifFieldName |
StringThe field to check. |
elseValue |
ObjectThe default value that will be returned. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifNull 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe expression to check. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the |
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 |
ExpressionThe 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 |
StringThe field to check. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the isNotNan operation. |
isType(Expression expr, String type)
public static BooleanExpression isType(Expression expr, String type)Creates an expression that checks if the result of an expression is of the given type.
Supported values for type are: "null", "array", "boolean", "bytes", "timestamp",
"geo_point", "number", "int32", "int64", "float64", "decimal128", "map", "reference", "string",
"vector", "max_key", "min_key", "object_id", "regex", and "request_timestamp".
| Parameters | |
|---|---|
| Name | Description |
expr |
ExpressionThe expression to check the type of. |
type |
StringThe type to check for. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression that evaluates to true if the expression's result is of the given type, false otherwise. |
isType(String fieldName, String type)
public static BooleanExpression isType(String fieldName, String type)Creates an expression that checks if the value of a field is of the given type.
Supported values for type are: "null", "array", "boolean", "bytes", "timestamp",
"geo_point", "number", "int32", "int64", "float64", "decimal128", "map", "reference", "string",
"vector", "max_key", "min_key", "object_id", "regex", and "request_timestamp".
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field to check the type of. |
type |
StringThe type to check for. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression that evaluates to true if the expression's result is of the given type, false otherwise. |
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 |
ExpressionThe expression representing the array. |
delimiterExpression |
ExpressionThe 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 |
ExpressionThe expression representing the array. |
delimiter |
StringThe 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 |
StringThe field name of the array. |
delimiterExpression |
ExpressionThe 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 |
StringThe field name of the array. |
delimiter |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe first expression. |
right |
ExpressionThe 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 |
ExpressionThe expression. |
right |
ObjectThe 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 |
StringThe field name. |
right |
ExpressionThe 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 |
StringThe field name. |
right |
ObjectThe 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 |
ExpressionThe first expression. |
right |
ExpressionThe 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 |
ExpressionThe expression. |
right |
ObjectThe 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 |
StringThe field name. |
right |
ExpressionThe 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 |
StringThe field name. |
right |
ObjectThe 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 |
ExpressionThe expression representing the string to perform the comparison on. |
pattern |
ExpressionThe 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 |
ExpressionThe expression representing the string to perform the comparison on. |
pattern |
StringThe 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 |
StringThe name of the field containing the string. |
pattern |
ExpressionThe 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 |
StringThe name of the field containing the string. |
pattern |
StringThe 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 |
ExpressionAn 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 |
StringName 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 |
ExpressionAn expression that returns number when evaluated. |
base |
ExpressionThe base of the logarithm. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from the logarithm of |
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 |
ExpressionAn expression that returns number when evaluated. |
base |
NumberThe base of the logarithm. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from the logarithm of |
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 |
StringName of field that returns number when evaluated. |
base |
ExpressionThe base of the logarithm. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from the logarithm of |
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 |
StringName of field that returns number when evaluated. |
base |
NumberThe base of the logarithm. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from the logarithm of |
log10(Expression numericExpr)
public static Expression log10(Expression numericExpr)Creates an expression that returns the base 10 logarithm of numericExpr.
| Parameter | |
|---|---|
| Name | Description |
numericExpr |
ExpressionAn 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 |
StringName 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe first operand field name. |
others |
Object[]Optional additional expressions or literals. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the logical minimum operation. |
ltrim(Expression value)
public static Expression ltrim(Expression value)Creates an expression that removes whitespace from the beginning of a string or blob.
| Parameter | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to trim. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
ltrim(String fieldName)
public static Expression ltrim(String fieldName)Creates an expression that removes whitespace from the beginning of a string or blob.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to trim. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string. |
ltrimValue(Expression value, Expression characters)
public static Expression ltrimValue(Expression value, Expression characters)Creates an expression that removes specified characters from the beginning of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to trim. |
characters |
ExpressionThe expression representing the characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
ltrimValue(Expression value, String characters)
public static Expression ltrimValue(Expression value, String characters)Creates an expression that removes specified characters from the beginning of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to trim. |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
ltrimValue(String fieldName, Expression characters)
public static Expression ltrimValue(String fieldName, Expression characters)Creates an expression that removes specified characters from the beginning of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to trim. |
characters |
ExpressionThe expression representing the characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
ltrimValue(String fieldName, String characters)
public static Expression ltrimValue(String fieldName, String characters)Creates an expression that removes specified characters from the beginning of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to trim. |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
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. |
mapEntries(Expression mapExpr)
public static Expression mapEntries(Expression mapExpr)Creates an expression that returns the entries of a map as an array of maps, where each map contains a "k" property for the key and a "v" property for the value.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Parameter | |
|---|---|
| Name | Description |
mapExpr |
ExpressionThe expression representing the map to get the entries of. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the entries of the map. |
mapEntries(String mapField)
public static Expression mapEntries(String mapField)Creates an expression that returns the entries of a map as an array of maps.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Parameter | |
|---|---|
| Name | Description |
mapField |
StringThe map field to get the entries of. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the entries of the map. |
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 |
ExpressionThe expression representing the map. |
key |
ExpressionThe 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 |
ExpressionThe expression representing the map. |
key |
StringThe 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 |
StringThe field name of the map field. |
key |
ExpressionThe 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 |
StringThe field name of the map field. |
key |
StringThe key to access in the map. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the value associated with the given key in the map. |
mapKeys(Expression mapExpr)
public static Expression mapKeys(Expression mapExpr)Creates an expression that returns the keys of a map.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Parameter | |
|---|---|
| Name | Description |
mapExpr |
ExpressionThe expression representing the map to get the keys of. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the keys of the map. |
mapKeys(String mapField)
public static Expression mapKeys(String mapField)Creates an expression that returns the keys of a map.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Parameter | |
|---|---|
| Name | Description |
mapField |
StringThe map field to get the keys of. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the keys of 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 |
ExpressionFirst map expression that will be merged. |
secondMap |
ExpressionSecond 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 |
StringField name of the first map expression that will be merged. |
secondMap |
ExpressionSecond 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 |
ExpressionThe expression representing the map. |
key |
ExpressionThe 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 |
ExpressionThe expression representing the map. |
key |
StringThe 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 |
StringThe field name of the map. |
key |
ExpressionThe 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 |
StringThe field name of the map. |
key |
StringThe key to remove from the map. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the key removed. |
mapSet(Expression mapExpr, Expression key, Expression value, Expression[] moreKeyValues)
public static Expression mapSet(Expression mapExpr, Expression key, Expression value, Expression[] moreKeyValues)Creates an expression that returns a new map with the specified entries added or updated.
- Only performs shallow updates to the map.
- Setting a value to
nullwill retain the key with anullvalue. To remove a key entirely, usemapRemove.
| Parameters | |
|---|---|
| Name | Description |
mapExpr |
ExpressionThe expression representing the map. |
key |
ExpressionThe key to set. Must be an expression representing a string. |
value |
ExpressionThe value to set. |
moreKeyValues |
Expression[]Additional key-value pairs to set. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the entries set. |
mapSet(Expression mapExpr, String key, Object value, Object[] moreKeyValues)
public static Expression mapSet(Expression mapExpr, String key, Object value, Object[] moreKeyValues)Creates an expression that returns a new map with the specified entries added or updated.
- Only performs shallow updates to the map.
- Setting a value to
nullwill retain the key with anullvalue. To remove a key entirely, usemapRemove.
| Parameters | |
|---|---|
| Name | Description |
mapExpr |
ExpressionThe map field to set entries in. |
key |
StringThe key to set. |
value |
ObjectThe value to set. |
moreKeyValues |
Object[]Additional key-value pairs to set. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the entries set. |
mapSet(String mapField, Expression key, Expression value, Expression[] moreKeyValues)
public static Expression mapSet(String mapField, Expression key, Expression value, Expression[] moreKeyValues)Creates an expression that returns a new map with the specified entries added or updated.
- Only performs shallow updates to the map.
- Setting a value to
nullwill retain the key with anullvalue. To remove a key entirely, usemapRemove.
| Parameters | |
|---|---|
| Name | Description |
mapField |
StringThe map field to set entries in. |
key |
ExpressionThe key to set. Must be an expression representing a string. |
value |
ExpressionThe value to set. |
moreKeyValues |
Expression[]Additional key-value pairs to set. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the entries set. |
mapSet(String mapField, String key, Object value, Object[] moreKeyValues)
public static Expression mapSet(String mapField, String key, Object value, Object[] moreKeyValues)Creates an expression that returns a new map with the specified entries added or updated.
- Only performs shallow updates to the map.
- Setting a value to
nullwill retain the key with anullvalue. To remove a key entirely, usemapRemove.
| Parameters | |
|---|---|
| Name | Description |
mapField |
StringThe map field to set entries in. |
key |
StringThe key to set. Must be an expression representing a string. |
value |
ObjectThe value to set. |
moreKeyValues |
Object[]Additional key-value pairs to set. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the entries set. |
mapValues(Expression mapExpr)
public static Expression mapValues(Expression mapExpr)Creates an expression that returns the values of a map.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Parameter | |
|---|---|
| Name | Description |
mapExpr |
ExpressionThe expression representing the map to get the values of. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the values of the map. |
mapValues(String mapField)
public static Expression mapValues(String mapField)Creates an expression that returns the values of a map.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Parameter | |
|---|---|
| Name | Description |
mapField |
StringThe map field to get the values of. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the values of the map. |
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 |
ExpressionThe numeric expression to be divided. |
divisor |
ExpressionThe 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 |
ExpressionThe numeric expression to be divided. |
divisor |
NumberThe 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 |
StringThe numeric field name to be divided. |
divisor |
ExpressionThe 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 |
StringThe numeric field name to be divided. |
divisor |
NumberThe 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 |
ExpressionNumeric expression to multiply. |
second |
ExpressionNumeric 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 |
ExpressionNumeric expression to multiply. |
second |
NumberConstant 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 |
StringNumeric field to multiply. |
second |
ExpressionNumeric 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 |
StringNumeric field to multiply. |
second |
NumberConstant to multiply. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the multiplication operation. |
nor(BooleanExpression condition, BooleanExpression[] conditions)
public static BooleanExpression nor(BooleanExpression condition, BooleanExpression[] conditions)Creates an expression that performs a logical 'NOR' operation.
| Parameters | |
|---|---|
| Name | Description |
condition |
BooleanExpressionThe first BooleanExpression. |
conditions |
BooleanExpression[]Additional BooleanExpressions. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the logical 'NOR' operation. |
not(BooleanExpression condition)
public static BooleanExpression not(BooleanExpression condition)Creates an expression that negates a boolean expression.
| Parameter | |
|---|---|
| Name | Description |
condition |
BooleanExpressionThe 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 |
ExpressionThe first expression. |
right |
ExpressionThe 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 |
ExpressionThe expression. |
right |
ObjectThe 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 |
StringThe field name. |
right |
ExpressionThe 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 |
StringThe field name. |
right |
ObjectThe 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 |
ExpressionThe expression whose results to compare. |
arrayExpression |
ExpressionAn 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 |
ExpressionThe 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 |
StringThe field to compare. |
arrayExpression |
ExpressionAn 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 |
StringThe 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 |
BooleanExpressionThe first BooleanExpression. |
conditions |
BooleanExpression[]Additional BooleanExpressions. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the logical 'OR' operation. |
parent(DocumentReference docRef)
public static Expression parent(DocumentReference docRef)Creates an expression that returns the parent document of a document reference.
| Parameter | |
|---|---|
| Name | Description |
docRef |
DocumentReferenceThe DocumentReference. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the parent operation. |
parent(Expression documentPath)
public static Expression parent(Expression documentPath)Creates an expression that returns the parent document of a document reference.
| Parameter | |
|---|---|
| Name | Description |
documentPath |
ExpressionAn expression that evaluates to a document path. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the parent operation. |
parent(String documentPath)
public static Expression parent(String documentPath)Creates an expression that returns the parent document of a document reference.
| Parameter | |
|---|---|
| Name | Description |
documentPath |
StringThe string representation of the document path. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the parent 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 |
ExpressionAn expression that returns number when evaluated. |
exponent |
ExpressionThe numeric power to raise the |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from raising |
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 |
ExpressionAn expression that returns number when evaluated. |
exponent |
NumberThe numeric power to raise the |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from raising |
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 |
StringName of field that returns number when evaluated. |
exponent |
ExpressionThe numeric power to raise the |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from raising |
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 |
StringName of field that returns number when evaluated. |
exponent |
NumberThe numeric power to raise the |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a numeric result from raising |
rand()
public static Expression rand()Creates an expression that returns a random double between 0.0 and 1.0 but not including 1.0.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing a random double result from the rand operation. |
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 |
StringThe 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 |
ExpressionThe expression representing the string to perform the comparison on. |
pattern |
ExpressionThe 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 |
ExpressionThe expression representing the string to perform the comparison on. |
pattern |
StringThe 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 |
StringThe name of the field containing the string. |
pattern |
ExpressionThe 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 |
StringThe name of the field containing the string. |
pattern |
StringThe regular expression to use for the search. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the contains regular expression comparison. |
regexFind(Expression string, Expression pattern)
public static Expression regexFind(Expression string, Expression pattern)Creates an expression that returns the first substring of a string expression that matches a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
string |
ExpressionThe expression representing the string to search. |
pattern |
ExpressionThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the regular expression find function. |
regexFind(Expression string, String pattern)
public static Expression regexFind(Expression string, String pattern)Creates an expression that returns the first substring of a string expression that matches a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
string |
ExpressionThe expression representing the string to search. |
pattern |
StringThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the regular expression find function. |
regexFind(String fieldName, Expression pattern)
public static Expression regexFind(String fieldName, Expression pattern)Creates an expression that returns the first substring of a string field that matches a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string to search. |
pattern |
ExpressionThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the regular expression find function. |
regexFind(String fieldName, String pattern)
public static Expression regexFind(String fieldName, String pattern)Creates an expression that returns the first substring of a string field that matches a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string to search. |
pattern |
StringThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the regular expression find function. |
regexFindAll(Expression string, Expression pattern)
public static Expression regexFindAll(Expression string, Expression pattern)Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
string |
ExpressionThe expression representing the string to search. |
pattern |
ExpressionThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression that evaluates to a list of matched substrings. |
regexFindAll(Expression string, String pattern)
public static Expression regexFindAll(Expression string, String pattern)Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
string |
ExpressionThe expression representing the string to search. |
pattern |
StringThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression that evaluates to a list of matched substrings. |
regexFindAll(String fieldName, Expression pattern)
public static Expression regexFindAll(String fieldName, Expression pattern)Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string to search. |
pattern |
ExpressionThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression that evaluates to a list of matched substrings. |
regexFindAll(String fieldName, String pattern)
public static Expression regexFindAll(String fieldName, String pattern)Creates an expression that evaluates to a list of all substrings in a string field that match a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string to search. |
pattern |
StringThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression that evaluates to a list of matched substrings. |
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 |
ExpressionThe expression representing the string to match against. |
pattern |
ExpressionThe 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 |
ExpressionThe expression representing the string to match against. |
pattern |
StringThe 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 |
StringThe name of the field containing the string. |
pattern |
ExpressionThe 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 |
StringThe name of the field containing the string. |
pattern |
StringThe 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 |
ExpressionAn 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 |
StringA 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 |
ExpressionAn 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 |
StringName 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 |
ExpressionAn expression that returns number when evaluated. |
decimalPlace |
ExpressionThe 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 |
ExpressionAn expression that returns number when evaluated. |
decimalPlace |
intThe 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 |
StringName of field that returns number when evaluated. |
decimalPlace |
ExpressionThe 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 |
StringName of field that returns number when evaluated. |
decimalPlace |
intThe number of decimal places to round. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the round operation. |
rtrim(Expression value)
public static Expression rtrim(Expression value)Creates an expression that removes whitespace from the end of a string or blob.
| Parameter | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to trim. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
rtrim(String fieldName)
public static Expression rtrim(String fieldName)Creates an expression that removes whitespace from the end of a string or blob.
| Parameter | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string to trim. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string. |
rtrimValue(Expression value, Expression characters)
public static Expression rtrimValue(Expression value, Expression characters)Creates an expression that removes specified characters from the end of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to trim. |
characters |
ExpressionThe expression representing the characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
rtrimValue(Expression value, String characters)
public static Expression rtrimValue(Expression value, String characters)Creates an expression that removes specified characters from the end of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to trim. |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
rtrimValue(String fieldName, Expression characters)
public static Expression rtrimValue(String fieldName, Expression characters)Creates an expression that removes specified characters from the end of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to trim. |
characters |
ExpressionThe expression representing the characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
rtrimValue(String fieldName, String characters)
public static Expression rtrimValue(String fieldName, String characters)Creates an expression that removes specified characters from the end of a string or blob.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to trim. |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
score()
public static Expression score()Evaluates to the search score that reflects the topicality of the document to all of the text
predicates (for example: documentMatches) in the search query.
This Expression can only be used within a Search stage.
Example:
db.pipeline().collection("restaurants").search(
Search.withQuery("waffles").withSort(score().descending())
)
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the score 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 |
ExpressionThe expression representing the string or blob to split. |
delimiter |
ExpressionThe 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 |
ExpressionThe expression representing the string or blob to split. |
delimiter |
StringThe 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 |
StringThe name of the field containing the string or blob to split. |
delimiter |
ExpressionThe 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 |
StringThe name of the field containing the string or blob to split. |
delimiter |
StringThe 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 |
ExpressionAn 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 |
StringName 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 |
ExpressionThe expression to check. |
prefix |
ExpressionThe 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 |
ExpressionThe expression to check. |
prefix |
StringThe 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 |
StringThe name of field that contains a string to check. |
prefix |
ExpressionThe 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 |
StringThe name of field that contains a string to check. |
prefix |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe expression representing the string to perform the comparison on. |
substring |
ExpressionThe 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 |
ExpressionThe expression representing the string to perform the comparison on. |
substring |
StringThe 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 |
StringThe name of the field to perform the comparison on. |
substring |
ExpressionThe 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 |
StringThe name of the field to perform the comparison on. |
substring |
StringThe substring to search for. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the contains comparison. |
stringIndexOf(Expression value, Expression search)
public static Expression stringIndexOf(Expression value, Expression search)Creates an expression that returns the index of the first occurrence of a substring or bytes.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the input string or blob. |
search |
ExpressionThe expression representing the search pattern. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
stringIndexOf(Expression value, String search)
public static Expression stringIndexOf(Expression value, String search)Creates an expression that returns the index of the first occurrence of a substring or bytes.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the input string or blob. |
search |
StringThe search pattern. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
stringIndexOf(String fieldName, Expression search)
public static Expression stringIndexOf(String fieldName, Expression search)Creates an expression that returns the index of the first occurrence of a substring or bytes.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the input string or blob. |
search |
ExpressionThe expression representing the search pattern. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
stringIndexOf(String fieldName, String search)
public static Expression stringIndexOf(String fieldName, String search)Creates an expression that returns the index of the first occurrence of a substring or bytes.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the input string or blob. |
search |
StringThe search pattern. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
stringRepeat(Expression value, Expression repetitions)
public static Expression stringRepeat(Expression value, Expression repetitions)Creates an expression that repeats a string or blob a specified number of times.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to repeat. |
repetitions |
ExpressionThe expression representing the number of times to repeat. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the repeated string or blob. |
stringRepeat(Expression value, Number repetitions)
public static Expression stringRepeat(Expression value, Number repetitions)Creates an expression that repeats a string or blob a specified number of times.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the string or blob to repeat. |
repetitions |
NumberThe number of times to repeat the string or blob. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the repeated string or blob. |
stringRepeat(String fieldName, Expression repetitions)
public static Expression stringRepeat(String fieldName, Expression repetitions)Creates an expression that repeats a string or blob a specified number of times.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to repeat. |
repetitions |
ExpressionThe expression representing the number of times to repeat. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the repeated string or blob. |
stringRepeat(String fieldName, Number repetitions)
public static Expression stringRepeat(String fieldName, Number repetitions)Creates an expression that repeats a string or blob a specified number of times.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the string or blob to repeat. |
repetitions |
NumberThe number of times to repeat the string or blob. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the repeated string or blob. |
stringReplaceAll(Expression value, Expression find, Expression replacement)
public static Expression stringReplaceAll(Expression value, Expression find, Expression replacement)Creates an expression that replaces all occurrences of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the input string or blob. |
find |
ExpressionThe expression representing the match pattern. |
replacement |
ExpressionThe expression representing the replacement value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceAll(Expression value, String find, String replacement)
public static Expression stringReplaceAll(Expression value, String find, String replacement)Creates an expression that replaces all occurrences of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the input string or blob. |
find |
StringThe match pattern. |
replacement |
StringThe replacement string/bytes. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceAll(String fieldName, Expression find, Expression replacement)
public static Expression stringReplaceAll(String fieldName, Expression find, Expression replacement)Creates an expression that replaces all occurrences of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the input string or blob. |
find |
ExpressionThe expression representing the match pattern. |
replacement |
ExpressionThe expression representing the replacement value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceAll(String fieldName, String find, String replacement)
public static Expression stringReplaceAll(String fieldName, String find, String replacement)Creates an expression that replaces all occurrences of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the input string or blob. |
find |
StringThe match pattern. |
replacement |
StringThe replacement string/bytes. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceOne(Expression value, Expression find, Expression replacement)
public static Expression stringReplaceOne(Expression value, Expression find, Expression replacement)Creates an expression that replaces the first occurrence of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the input string or blob. |
find |
ExpressionThe expression representing the match pattern. |
replacement |
ExpressionThe expression representing the replacement value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceOne(Expression value, String find, String replacement)
public static Expression stringReplaceOne(Expression value, String find, String replacement)Creates an expression that replaces the first occurrence of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
value |
ExpressionThe expression representing the input string or blob. |
find |
StringThe match pattern. |
replacement |
StringThe replacement string/bytes. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceOne(String fieldName, Expression find, Expression replacement)
public static Expression stringReplaceOne(String fieldName, Expression find, Expression replacement)Creates an expression that replaces the first occurrence of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the input string or blob. |
find |
ExpressionThe expression representing the match pattern. |
replacement |
ExpressionThe expression representing the replacement value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceOne(String fieldName, String find, String replacement)
public static Expression stringReplaceOne(String fieldName, String find, String replacement)Creates an expression that replaces the first occurrence of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the input string or blob. |
find |
StringThe match pattern. |
replacement |
StringThe replacement string/bytes. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
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 |
ExpressionThe expression representing the string to get a substring from. |
index |
ExpressionThe starting index of the substring. |
length |
ExpressionThe 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 |
StringThe name of the field containing the string to get a substring from. |
index |
intThe starting index of the substring. |
length |
intThe 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 |
ExpressionNumeric expression to subtract from. |
subtrahend |
ExpressionNumeric 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 |
ExpressionNumeric expression to subtract from. |
subtrahend |
NumberConstant 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 |
StringNumeric field to subtract from. |
subtrahend |
ExpressionNumeric 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 |
StringNumeric field to subtract from. |
subtrahend |
NumberConstant to subtract. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the subtract operation. |
switchOn(BooleanExpression condition, Expression result, Object[] others)
public static Expression switchOn(BooleanExpression condition, Expression result, Object[] others)Creates an expression that evaluates to the result corresponding to the first true condition.
This function behaves like a switch statement. It accepts an alternating sequence of
conditions and their corresponding results. If an odd number of arguments is provided, the
final argument serves as a default fallback result. If no default is provided and no condition
evaluates to true, it throws an error.
| Parameters | |
|---|---|
| Name | Description |
condition |
BooleanExpressionThe first BooleanExpression. |
result |
ExpressionThe result if the first condition is true. |
others |
Object[]Additional conditions and results, and optionally a default value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the switchOn 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 |
ExpressionThe expression representing the timestamp. |
unit |
ExpressionThe expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
ExpressionThe 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 |
ExpressionThe expression representing the timestamp. |
unit |
StringThe unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
longThe 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 |
StringThe name of the field that contains the timestamp. |
unit |
ExpressionThe expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
ExpressionThe 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 |
StringThe name of the field that contains the timestamp. |
unit |
StringThe unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
longThe amount of time to add. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the resulting timestamp. |
timestampDiff(Expression end, Expression start, Expression unit)
public static Expression timestampDiff(Expression end, Expression start, Expression unit)Creates an expression that calculates the difference between two timestamps.
| Parameters | |
|---|---|
| Name | Description |
end |
ExpressionThe ending timestamp expression. |
start |
ExpressionThe starting timestamp expression. |
unit |
ExpressionThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampDiff(Expression end, Expression start, String unit)
public static Expression timestampDiff(Expression end, Expression start, String unit)Creates an expression that calculates the difference between two timestamps.
| Parameters | |
|---|---|
| Name | Description |
end |
ExpressionThe ending timestamp expression. |
start |
ExpressionThe starting timestamp expression. |
unit |
StringThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampDiff(Expression end, String startFieldName, String unit)
public static Expression timestampDiff(Expression end, String startFieldName, String unit)Creates an expression that calculates the difference between two timestamps.
| Parameters | |
|---|---|
| Name | Description |
end |
ExpressionThe ending timestamp expression. |
startFieldName |
StringThe starting timestamp field name. |
unit |
StringThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampDiff(String endFieldName, Expression start, String unit)
public static Expression timestampDiff(String endFieldName, Expression start, String unit)Creates an expression that calculates the difference between two timestamps.
| Parameters | |
|---|---|
| Name | Description |
endFieldName |
StringThe ending timestamp field name. |
start |
ExpressionThe starting timestamp expression. |
unit |
StringThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampDiff(String endFieldName, String startFieldName, String unit)
public static Expression timestampDiff(String endFieldName, String startFieldName, String unit)Creates an expression that calculates the difference between two timestamps.
| Parameters | |
|---|---|
| Name | Description |
endFieldName |
StringThe ending timestamp field name. |
startFieldName |
StringThe starting timestamp field name. |
unit |
StringThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampExtract(Expression timestamp, Expression part)
public static Expression timestampExtract(Expression timestamp, Expression part)Creates an expression that extracts a specified part from a timestamp.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
part |
ExpressionThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "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 extracted part. |
timestampExtract(Expression timestamp, String part)
public static Expression timestampExtract(Expression timestamp, String part)Creates an expression that extracts a specified part from a timestamp.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
part |
StringThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "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 extracted part. |
timestampExtract(String fieldName, Expression part)
public static Expression timestampExtract(String fieldName, Expression part)Creates an expression that extracts a specified part from a timestamp.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
part |
ExpressionThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "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 extracted part. |
timestampExtract(String fieldName, String part)
public static Expression timestampExtract(String fieldName, String part)Creates an expression that extracts a specified part from a timestamp.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
part |
StringThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "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 extracted part. |
timestampExtractWithTimezone(Expression timestamp, Expression part, Expression timezone)
public static Expression timestampExtractWithTimezone(Expression timestamp, Expression part, Expression timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
part |
ExpressionThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
ExpressionThe timezone expression to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(Expression timestamp, Expression part, String timezone)
public static Expression timestampExtractWithTimezone(Expression timestamp, Expression part, String timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
part |
ExpressionThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
StringThe timezone to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(Expression timestamp, String part, Expression timezone)
public static Expression timestampExtractWithTimezone(Expression timestamp, String part, Expression timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
part |
StringThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
ExpressionThe timezone expression to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(Expression timestamp, String part, String timezone)
public static Expression timestampExtractWithTimezone(Expression timestamp, String part, String timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
part |
StringThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
StringThe timezone to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(String fieldName, Expression part, Expression timezone)
public static Expression timestampExtractWithTimezone(String fieldName, Expression part, Expression timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
part |
ExpressionThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
ExpressionThe timezone expression to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(String fieldName, Expression part, String timezone)
public static Expression timestampExtractWithTimezone(String fieldName, Expression part, String timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
part |
ExpressionThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
StringThe timezone to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(String fieldName, String part, Expression timezone)
public static Expression timestampExtractWithTimezone(String fieldName, String part, Expression timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
part |
StringThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
ExpressionThe timezone expression to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(String fieldName, String part, String timezone)
public static Expression timestampExtractWithTimezone(String fieldName, String part, String timezone)Creates an expression that extracts a specified part from a timestamp in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
part |
StringThe part to extract from the timestamp. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
StringThe timezone to use for extraction.Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
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 |
ExpressionThe expression representing the timestamp. |
unit |
ExpressionThe expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
ExpressionThe 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 |
ExpressionThe expression representing the timestamp. |
unit |
StringThe unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
longThe 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 |
StringThe name of the field that contains the timestamp. |
unit |
ExpressionThe unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
ExpressionThe 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 |
StringThe name of the field that contains the timestamp. |
unit |
StringThe unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
longThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe timestamp expression. |
granularity |
ExpressionThe 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, 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 |
ExpressionThe timestamp expression. |
granularity |
StringThe 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, 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 |
StringThe name of the field containing the timestamp. |
granularity |
ExpressionThe 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, 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 |
StringThe name of the field containing the timestamp. |
granularity |
StringThe 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. |
timestampTruncateWithTimezone(Expression timestamp, Expression granularity, Expression timezone)
public static Expression timestampTruncateWithTimezone(Expression timestamp, Expression granularity, Expression timezone)Creates an expression that truncates a timestamp to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
granularity |
ExpressionThe 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 |
ExpressionThe timezone expression 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. |
timestampTruncateWithTimezone(Expression timestamp, Expression granularity, String timezone)
public static Expression timestampTruncateWithTimezone(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 |
ExpressionThe timestamp expression. |
granularity |
ExpressionThe 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 |
StringThe 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. |
timestampTruncateWithTimezone(Expression timestamp, String granularity, Expression timezone)
public static Expression timestampTruncateWithTimezone(Expression timestamp, String granularity, Expression timezone)Creates an expression that truncates a timestamp to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
timestamp |
ExpressionThe timestamp expression. |
granularity |
StringThe 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 |
ExpressionThe timezone expression 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. |
timestampTruncateWithTimezone(Expression timestamp, String granularity, String timezone)
public static Expression timestampTruncateWithTimezone(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 |
ExpressionThe timestamp expression. |
granularity |
StringThe 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 |
StringThe 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. |
timestampTruncateWithTimezone(String fieldName, Expression granularity, Expression timezone)
public static Expression timestampTruncateWithTimezone(String fieldName, Expression granularity, Expression timezone)Creates an expression that truncates a timestamp to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
granularity |
ExpressionThe 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 |
ExpressionThe timezone expression 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. |
timestampTruncateWithTimezone(String fieldName, Expression granularity, String timezone)
public static Expression timestampTruncateWithTimezone(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 |
StringThe name of the field containing the timestamp. |
granularity |
ExpressionThe 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 |
StringThe 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. |
timestampTruncateWithTimezone(String fieldName, String granularity, Expression timezone)
public static Expression timestampTruncateWithTimezone(String fieldName, String granularity, Expression timezone)Creates an expression that truncates a timestamp to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
fieldName |
StringThe name of the field containing the timestamp. |
granularity |
StringThe 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 |
ExpressionThe timezone expression 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. |
timestampTruncateWithTimezone(String fieldName, String granularity, String timezone)
public static Expression timestampTruncateWithTimezone(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 |
StringThe name of the field containing the timestamp. |
granularity |
StringThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe expression representing the string or blob to trim. |
characters |
ExpressionThe 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 |
ExpressionThe expression representing the string or blob to trim. |
characters |
StringThe 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 |
StringThe name of the field containing the string or blob to trim. |
characters |
ExpressionThe 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 |
StringThe name of the field containing the string or blob to trim. |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
trunc(Expression numericExpr)
public static Expression trunc(Expression numericExpr)Creates an expression that truncates numericExpr to an integer.
| Parameter | |
|---|---|
| Name | Description |
numericExpr |
ExpressionAn expression that returns number when evaluated. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
trunc(String numericField)
public static Expression trunc(String numericField)Creates an expression that truncates numericField to an integer.
| Parameter | |
|---|---|
| Name | Description |
numericField |
StringName of field that returns number when evaluated. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
truncToPrecision(Expression numericExpr, Expression decimalPlace)
public static Expression truncToPrecision(Expression numericExpr, Expression decimalPlace)Creates an expression that truncates numericExpr to decimalPlace decimal places
if decimalPlace is positive, truncates digits to the left of the decimal point if
decimalPlace is negative.
| Parameters | |
|---|---|
| Name | Description |
numericExpr |
ExpressionAn expression that returns number when evaluated. |
decimalPlace |
ExpressionThe number of decimal places to truncate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
truncToPrecision(Expression numericExpr, int decimalPlace)
public static Expression truncToPrecision(Expression numericExpr, int decimalPlace)Creates an expression that truncates numericExpr to decimalPlace decimal places
if decimalPlace is positive, truncates digits to the left of the decimal point if
decimalPlace is negative.
| Parameters | |
|---|---|
| Name | Description |
numericExpr |
ExpressionAn expression that returns number when evaluated. |
decimalPlace |
intThe number of decimal places to truncate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
truncToPrecision(String numericField, Expression decimalPlace)
public static Expression truncToPrecision(String numericField, Expression decimalPlace)Creates an expression that truncates numericField to decimalPlace decimal
places if decimalPlace is positive, truncates digits to the left of the decimal point
if decimalPlace is negative.
| Parameters | |
|---|---|
| Name | Description |
numericField |
StringName of field that returns number when evaluated. |
decimalPlace |
ExpressionThe number of decimal places to truncate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
truncToPrecision(String numericField, int decimalPlace)
public static Expression truncToPrecision(String numericField, int decimalPlace)Creates an expression that truncates numericField to decimalPlace decimal
places if decimalPlace is positive, truncates digits to the left of the decimal point
if decimalPlace is negative.
| Parameters | |
|---|---|
| Name | Description |
numericField |
StringName of field that returns number when evaluated. |
decimalPlace |
intThe number of decimal places to truncate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe 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 |
ExpressionThe 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 |
StringThe name of the field containing the number of seconds since epoch. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the timestamp. |
variable(String name)
public static Expression variable(String name)Creates an expression that retrieves the value of a variable bound via Pipeline#define(AliasedExpression, AliasedExpression...).
Example:
// Define a variable "discountedPrice" and use it in a filter
firestore.pipeline().collection("products")
.define(field("price").multiply(0.9).as("discountedPrice"))
.where(variable("discountedPrice").lessThan(100));
| Parameter | |
|---|---|
| Name | Description |
name |
StringThe name of the variable to retrieve. |
| Returns | |
|---|---|
| Type | Description |
Expression |
An Expression representing the variable's value. |
vectorLength(Expression vectorExpression)
public static Expression vectorLength(Expression vectorExpression)Creates an expression that calculates the length of a vector.
| Parameter | |
|---|---|
| Name | Description |
vectorExpression |
ExpressionThe 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 |
StringThe 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 |
BooleanExpressionThe 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 |
ObjectNumeric expression to add. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the addition operation. |
arrayAgg()
public final AggregateFunction arrayAgg()Creates an aggregation that collects all values of this expression across multiple stage inputs into an array.
If the expression resolves to an absent value, it is converted to null. The order of
elements in the output array is not stable and shouldn't be relied upon.
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the array_agg aggregation. |
arrayAggDistinct()
public final AggregateFunction arrayAggDistinct()Creates an aggregation that collects all distinct values of this expression across multiple stage inputs into an array.
If the expression resolves to an absent value, it is converted to null. The order of
elements in the output array is not stable and shouldn't be relied upon.
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the array_agg_distinct aggregation. |
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 |
ObjectThe 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 |
ExpressionThe 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 |
ExpressionThe 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. |
arrayFilter(String alias, BooleanExpression filter)
public final Expression arrayFilter(String alias, BooleanExpression filter)Filters this array based on a predicate.
| Parameters | |
|---|---|
| Name | Description |
alias |
StringThe alias for the current element in the filter expression. |
filter |
BooleanExpressionThe predicate boolean expression used to filter the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the filtered array. |
arrayFirst()
public final Expression arrayFirst()Returns the first element of an array.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first element of the array. |
arrayFirstN(Expression n)
public final Expression arrayFirstN(Expression n)Returns the first n elements of an array.
| Parameter | |
|---|---|
| Name | Description |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first n elements of the array. |
arrayFirstN(int n)
public final Expression arrayFirstN(int n)Returns the first n elements of an array.
| Parameter | |
|---|---|
| Name | Description |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the first n elements of the array. |
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 |
ExpressionAn 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 |
intAn Expression evaluating to the index of the element to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the arrayOffset operation. |
arrayIndexOf(Expression value)
public final Expression arrayIndexOf(Expression value)Returns the index of the first occurrence of a value in an array.
| Parameter | |
|---|---|
| Name | Description |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
arrayIndexOf(Object value)
public final Expression arrayIndexOf(Object value)Returns the index of the first occurrence of a value in an array.
| Parameter | |
|---|---|
| Name | Description |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
arrayIndexOfAll(Expression value)
public final Expression arrayIndexOfAll(Expression value)Returns all indices of a value in an array.
| Parameter | |
|---|---|
| Name | Description |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the indices. |
arrayIndexOfAll(Object value)
public final Expression arrayIndexOfAll(Object value)Returns all indices of a value in an array.
| Parameter | |
|---|---|
| Name | Description |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the indices. |
arrayLast()
public final Expression arrayLast()Returns the last element of an array.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last element of the array. |
arrayLastIndexOf(Expression value)
public final Expression arrayLastIndexOf(Expression value)Returns the index of the last occurrence of a value in an array.
| Parameter | |
|---|---|
| Name | Description |
value |
ExpressionThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last index. |
arrayLastIndexOf(Object value)
public final Expression arrayLastIndexOf(Object value)Returns the index of the last occurrence of a value in an array.
| Parameter | |
|---|---|
| Name | Description |
value |
ObjectThe value to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last index. |
arrayLastN(Expression n)
public final Expression arrayLastN(Expression n)Returns the last n elements of an array.
| Parameter | |
|---|---|
| Name | Description |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last n elements of the array. |
arrayLastN(int n)
public final Expression arrayLastN(int n)Returns the last n elements of an array.
| Parameter | |
|---|---|
| Name | Description |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the last n elements of the array. |
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. |
arrayMaximum()
public final Expression arrayMaximum()Returns the maximum value of an array.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the maximum value of the array. |
arrayMaximumN(Expression n)
public final Expression arrayMaximumN(Expression n)Returns the n maximum values of an array.
Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameter | |
|---|---|
| Name | Description |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n maximum values of the array. |
arrayMaximumN(int n)
public final Expression arrayMaximumN(int n)Returns the n maximum values of an array.
Note: Returns the n largest non-null elements in the array, in descending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameter | |
|---|---|
| Name | Description |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n maximum values of the array. |
arrayMinimum()
public final Expression arrayMinimum()Returns the minimum value of an array.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the minimum value of the array. |
arrayMinimumN(Expression n)
public final Expression arrayMinimumN(Expression n)Returns the n minimum values of an array.
Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameter | |
|---|---|
| Name | Description |
n |
ExpressionThe Expression evaluates to the number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n minimum values of the array. |
arrayMinimumN(int n)
public final Expression arrayMinimumN(int n)Returns the n minimum values of an array.
Note: Returns the n smallest non-null elements in the array, in ascending order. This does not use a stable sort, meaning the order of equivalent elements is undefined.
| Parameter | |
|---|---|
| Name | Description |
n |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the n minimum values 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. |
arraySlice(Expression offset, Expression length)
public final Expression arraySlice(Expression offset, Expression length)Returns a slice of this array.
| Parameters | |
|---|---|
| Name | Description |
offset |
ExpressionThe starting index expressed as an Expression. |
length |
ExpressionThe number of elements to return expressed as an Expression. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySlice(int offset, int length)
public final Expression arraySlice(int offset, int length)Returns a slice of this array.
| Parameters | |
|---|---|
| Name | Description |
offset |
intThe starting index. |
length |
intThe number of elements to return. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySliceToEnd(Expression offset)
public final Expression arraySliceToEnd(Expression offset)Returns a slice of this array to its end.
| Parameter | |
|---|---|
| Name | Description |
offset |
ExpressionThe starting index expressed as an Expression. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
arraySliceToEnd(int offset)
public final Expression arraySliceToEnd(int offset)Returns a slice of this array to its end.
| Parameter | |
|---|---|
| Name | Description |
offset |
intThe starting index. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the array slice. |
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. |
arrayTransform(String elementAlias, Expression transform)
public final Expression arrayTransform(String elementAlias, Expression transform)Creates an expression that applies a provided transformation to each element in an array.
| Parameters | |
|---|---|
| Name | Description |
elementAlias |
StringThe alias for the current element in the transform expression. |
transform |
ExpressionThe expression used to transform the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the transformed array. |
arrayTransformWithIndex(String elementAlias, String indexAlias, Expression transform)
public final Expression arrayTransformWithIndex(String elementAlias, String indexAlias, Expression transform)Creates an expression that applies a provided transformation to each element in an array, providing the element's index to the transformation expression.
| Parameters | |
|---|---|
| Name | Description |
elementAlias |
StringThe alias for the current element in the transform expression. |
indexAlias |
StringThe alias for the current index. |
transform |
ExpressionThe expression used to transform the elements. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the transformed array. |
as(String alias)
public AliasedExpression 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 |
StringThe alias to assign to this expression. |
| Returns | |
|---|---|
| Type | Description |
AliasedExpression |
A new 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. |
between(Expression lowerBound, Expression upperBound)
public final BooleanExpression between(Expression lowerBound, Expression upperBound)| Parameters | |
|---|---|
| Name | Description |
lowerBound |
Expression |
upperBound |
Expression |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
|
between(Object lowerBound, Object upperBound)
public final BooleanExpression between(Object lowerBound, Object upperBound)| Parameters | |
|---|---|
| Name | Description |
lowerBound |
Object |
upperBound |
Object |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
|
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. |
coalesce(Object second, Object[] others)
public Expression coalesce(Object second, Object[] others)Returns the first non-null, non-absent argument, without evaluating the rest of the arguments. When all arguments are null or absent, returns the last argument.
| Parameters | |
|---|---|
| Name | Description |
second |
ObjectThe next expression or literal to evaluate. |
others |
Object[]Additional expressions or literals to evaluate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the coalesce 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 |
ExpressionThe 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 |
ObjectNumeric 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 |
ExpressionThe 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 |
ObjectThe 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 |
ObjectThe 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 |
ExpressionThe 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. |
first()
public final AggregateFunction first()Creates an aggregation that finds the first value of this expression across multiple stage inputs.
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the first aggregation. |
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. |
getField(Expression keyExpression)
public Expression getField(Expression keyExpression)Retrieves the value of a specific field from the document evaluated by this expression.
| Parameter | |
|---|---|
| Name | Description |
keyExpression |
ExpressionThe expression evaluating to the key to access. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the field value. |
getField(String key)
public Expression getField(String key)Accesses a field/property of the expression that evaluates to a Map or Document.
| Parameter | |
|---|---|
| Name | Description |
key |
StringThe key of the field to access. |
| Returns | |
|---|---|
| Type | Description |
Expression |
An Expression representing the value of the field. |
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 |
ObjectThe 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 |
ObjectThe 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 |
ObjectThe 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 |
ExpressionThe 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 |
ObjectThe value that will be returned if this expression produces an error. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifError operation. |
ifNull(Object elseValue)
public Expression ifNull(Object elseValue)Creates an expression that returns a default value if this expression evaluates null.
Note: This function provides a fallback for both absent and explicit null values. In contrast, ifAbsent only triggers for missing fields.
| Parameter | |
|---|---|
| Name | Description |
elseValue |
ObjectThe default value that will be returned. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the ifNull 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 |
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. |
isType(String type)
public final BooleanExpression isType(String type)Creates an expression that checks if the result of this expression is of the given type.
Supported values for type are: "null", "array", "boolean", "bytes", "timestamp",
"geo_point", "number", "int32", "int64", "float64", "decimal128", "map", "reference", "string",
"vector", "max_key", "min_key", "object_id", "regex", and "request_timestamp".
| Parameter | |
|---|---|
| Name | Description |
type |
StringThe type to check for. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression that evaluates to true if the expression's result is of the given type, false otherwise. |
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 |
ExpressionThe 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 |
StringThe delimiter to use. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the join operation. |
last()
public final AggregateFunction last()Creates an aggregation that finds the last value of this expression across multiple stage inputs.
| Returns | |
|---|---|
| Type | Description |
AggregateFunction |
A new AggregateFunction representing the last aggregation. |
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 |
ObjectThe 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 |
ObjectThe 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 |
ObjectThe 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. |
ltrim()
public Expression ltrim()Creates an expression that removes whitespace from the beginning of this string or blob expression.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
ltrimValue(Expression characters)
public Expression ltrimValue(Expression characters)Creates an expression that removes the specified characters or bytes from the beginning of this string or blob expression.
| Parameter | |
|---|---|
| Name | Description |
characters |
ExpressionThe expression representing the characters or bytes to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
ltrimValue(String characters)
public Expression ltrimValue(String characters)Creates an expression that removes the specified set of characters from the beginning of this string or blob expression.
| Parameter | |
|---|---|
| Name | Description |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
mapEntries()
public final Expression mapEntries()Creates an expression that returns the entries of this map expression as an array of maps, where each map contains a "k" property for the key and a "v" property for the value.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the entries of the map. |
mapGet(Object key)
public final Expression mapGet(Object key)Accesses a map (object) value using the provided key.
| Parameter | |
|---|---|
| Name | Description |
key |
ObjectThe key to access in the map. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the value associated with the given key in the map. |
mapKeys()
public final Expression mapKeys()Creates an expression that returns the keys of this map expression.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the keys of 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 |
ExpressionMap 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 |
ExpressionThe 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 |
StringThe name of the key to remove from this map expression. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression that evaluates to a modified map. |
mapSet(Expression key, Expression value, Expression[] moreKeyValues)
public final Expression mapSet(Expression key, Expression value, Expression[] moreKeyValues)Creates an expression that returns a new map with the specified entries added or updated.
Note that mapSet only performs shallow updates to the map. Setting a value to
null will retain the key with a null value. To remove a key entirely, use
mapRemove.
| Parameters | |
|---|---|
| Name | Description |
key |
ExpressionThe key to set. |
value |
ExpressionThe value to set. |
moreKeyValues |
Expression[]Additional key-value pairs to set. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the entries set. |
mapSet(String key, Object value, Object[] moreKeyValues)
public final Expression mapSet(String key, Object value, Object[] moreKeyValues)Creates an expression that returns a new map with the specified entries added or updated.
| Parameters | |
|---|---|
| Name | Description |
key |
StringThe key to set. |
value |
ObjectThe value to set. |
moreKeyValues |
Object[]Additional key-value pairs to set. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the map with the entries set. |
mapValues()
public final Expression mapValues()Creates an expression that returns the values of this map expression.
While the backend generally preserves insertion order, relying on the order of the output array is not guaranteed and should be avoided.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the values of the 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 |
ObjectThe 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 |
ObjectNumeric 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 |
ObjectThe 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. |
parent()
public final Expression parent()Creates an expression that returns the parent document of a document reference.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the parent operation. |
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 |
ExpressionThe 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 |
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 |
NumberThe 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 |
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 |
ObjectThe regular expression to use for the search. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the contains regular expression comparison. |
regexFind(Object pattern)
public final Expression regexFind(Object pattern)Creates an expression that returns the first substring of a string expression that matches a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameter | |
|---|---|
| Name | Description |
pattern |
ObjectThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the regular expression find function. |
regexFindAll(Object pattern)
public final Expression regexFindAll(Object pattern)Creates an expression that evaluates to a list of all substrings in a string expression that match a specified regular expression.
This expression uses the RE2 regular expression syntax.
| Parameter | |
|---|---|
| Name | Description |
pattern |
ObjectThe regular expression to search for. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression that evaluates to a list of matched substrings. |
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 |
ObjectThe 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 |
ExpressionThe 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 |
intThe number of decimal places to round. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the round operation. |
rtrim()
public Expression rtrim()Creates an expression that removes whitespace from the end of this string or blob expression.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
rtrimValue(Expression characters)
public Expression rtrimValue(Expression characters)Creates an expression that removes the specified characters or bytes from the end of this string or blob expression.
| Parameter | |
|---|---|
| Name | Description |
characters |
ExpressionThe expression representing the characters or bytes to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
rtrimValue(String characters)
public Expression rtrimValue(String characters)Creates an expression that removes the specified set of characters from the end of this string or blob expression.
| Parameter | |
|---|---|
| Name | Description |
characters |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
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 |
ExpressionThe 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 |
StringThe 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 |
ObjectThe 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 |
ObjectThe expression representing the substring to search for. |
| Returns | |
|---|---|
| Type | Description |
BooleanExpression |
A new BooleanExpression representing the contains comparison. |
stringIndexOf(Expression search)
public Expression stringIndexOf(Expression search)Creates an expression that returns the index of the first occurrence of a substring or bytes.
| Parameter | |
|---|---|
| Name | Description |
search |
ExpressionThe expression representing the search pattern. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
stringIndexOf(String search)
public Expression stringIndexOf(String search)Creates an expression that returns the index of the first occurrence of a substring or bytes.
| Parameter | |
|---|---|
| Name | Description |
search |
StringThe search pattern. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the index. |
stringRepeat(Expression repetitions)
public Expression stringRepeat(Expression repetitions)Creates an expression that repeats a string or blob a specified number of times.
| Parameter | |
|---|---|
| Name | Description |
repetitions |
ExpressionThe expression representing the number of times to repeat. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the repeated string or blob. |
stringRepeat(Number repetitions)
public Expression stringRepeat(Number repetitions)Creates an expression that repeats a string or blob a specified number of times.
| Parameter | |
|---|---|
| Name | Description |
repetitions |
NumberThe number of times to repeat the string or blob. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the repeated string or blob. |
stringReplaceAll(Expression find, Expression replacement)
public Expression stringReplaceAll(Expression find, Expression replacement)Creates an expression that replaces all occurrences of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
find |
ExpressionThe expression representing the match pattern. |
replacement |
ExpressionThe expression representing the replacement value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceAll(String find, String replacement)
public Expression stringReplaceAll(String find, String replacement)Creates an expression that replaces all occurrences of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
find |
StringThe match pattern. |
replacement |
StringThe replacement string/bytes. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceOne(Expression find, Expression replacement)
public Expression stringReplaceOne(Expression find, Expression replacement)Creates an expression that replaces the first occurrence of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
find |
ExpressionThe expression representing the match pattern. |
replacement |
ExpressionThe expression representing the replacement value. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
stringReplaceOne(String find, String replacement)
public Expression stringReplaceOne(String find, String replacement)Creates an expression that replaces the first occurrence of a substring or byte sequence.
| Parameters | |
|---|---|
| Name | Description |
find |
StringThe match pattern. |
replacement |
StringThe replacement string/bytes. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the replaced value. |
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 |
ObjectThe starting index of the substring. |
length |
ObjectThe 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 |
ObjectConstant 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 |
ExpressionThe expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
ExpressionThe 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 |
StringThe unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
longThe amount of time to add. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the resulting timestamp. |
timestampDiff(Expression start, Expression unit)
public final Expression timestampDiff(Expression start, Expression unit)Calculates the difference between this timestamp and another timestamp.
| Parameters | |
|---|---|
| Name | Description |
start |
ExpressionThe starting timestamp expression. |
unit |
ExpressionThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampDiff(Expression start, String unit)
public final Expression timestampDiff(Expression start, String unit)Calculates the difference between this timestamp and another timestamp.
| Parameters | |
|---|---|
| Name | Description |
start |
ExpressionThe starting timestamp expression. |
unit |
StringThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampDiff(String startFieldName, String unit)
public final Expression timestampDiff(String startFieldName, String unit)Calculates the difference between this timestamp and another timestamp.
| Parameters | |
|---|---|
| Name | Description |
startFieldName |
StringThe name of the field containing the starting timestamp. |
unit |
StringThe unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the difference. |
timestampExtract(Expression part)
public final Expression timestampExtract(Expression part)Creates an expression that extracts a specified part from this timestamp expression.
| Parameter | |
|---|---|
| Name | Description |
part |
ExpressionThe part to extract. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "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 extracted part. |
timestampExtract(String part)
public final Expression timestampExtract(String part)Creates an expression that extracts a specified part from this timestamp expression.
| Parameter | |
|---|---|
| Name | Description |
part |
StringThe part to extract. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "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 extracted part. |
timestampExtractWithTimezone(Expression part, Expression timezone)
public final Expression timestampExtractWithTimezone(Expression part, Expression timezone)Creates an expression that extracts a specified part from this timestamp expression in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
part |
ExpressionThe part to extract. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
ExpressionThe timezone expression to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(Expression part, String timezone)
public final Expression timestampExtractWithTimezone(Expression part, String timezone)Creates an expression that extracts a specified part from this timestamp expression in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
part |
ExpressionThe part to extract. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
StringThe timezone to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(String part, Expression timezone)
public final Expression timestampExtractWithTimezone(String part, Expression timezone)Creates an expression that extracts a specified part from this timestamp expression in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
part |
StringThe part to extract. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
ExpressionThe timezone expression to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
timestampExtractWithTimezone(String part, String timezone)
public final Expression timestampExtractWithTimezone(String part, String timezone)Creates an expression that extracts a specified part from this timestamp expression in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
part |
StringThe part to extract. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "dayofweek", "day", "dayofyear", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear". |
timezone |
StringThe timezone to use for extraction. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the extracted part. |
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 |
ExpressionThe expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
ExpressionThe 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 |
StringThe unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day". |
amount |
longThe 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 |
ExpressionThe 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 |
StringThe 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. |
timestampTruncateWithTimezone(Expression granularity, Expression timezone)
public final Expression timestampTruncateWithTimezone(Expression granularity, Expression timezone)Creates an expression that truncates this timestamp expression to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
granularity |
ExpressionThe 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 |
ExpressionThe timezone expression 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. |
timestampTruncateWithTimezone(Expression granularity, String timezone)
public final Expression timestampTruncateWithTimezone(Expression granularity, String timezone)Creates an expression that truncates this timestamp expression to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
granularity |
ExpressionThe 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 |
StringThe 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. |
timestampTruncateWithTimezone(String granularity, Expression timezone)
public final Expression timestampTruncateWithTimezone(String granularity, Expression timezone)Creates an expression that truncates this timestamp expression to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
granularity |
StringThe 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 |
ExpressionThe timezone expression 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. |
timestampTruncateWithTimezone(String granularity, String timezone)
public final Expression timestampTruncateWithTimezone(String granularity, String timezone)Creates an expression that truncates this timestamp expression to a specified granularity in a given timezone.
| Parameters | |
|---|---|
| Name | Description |
granularity |
StringThe 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 |
StringThe timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified. |
| 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 |
ExpressionThe 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 |
StringThe characters to remove. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trimmed string or blob. |
trunc()
public final Expression trunc()Creates an expression that truncates this numeric expression to an integer.
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
truncToPrecision(Expression decimalPlace)
public final Expression truncToPrecision(Expression decimalPlace)Creates an expression that truncates this numeric expression to decimalPlace decimal
places if decimalPlace is positive, truncates digits to the left of the decimal point
if decimalPlace is negative.
| Parameter | |
|---|---|
| Name | Description |
decimalPlace |
ExpressionThe number of decimal places to truncate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
truncToPrecision(int decimalPlace)
public final Expression truncToPrecision(int decimalPlace)Creates an expression that truncates this numeric expression to decimalPlace decimal
places if decimalPlace is positive, truncates digits to the left of the decimal point
if decimalPlace is negative.
| Parameter | |
|---|---|
| Name | Description |
decimalPlace |
intThe number of decimal places to truncate. |
| Returns | |
|---|---|
| Type | Description |
Expression |
A new Expression representing the trunc operation. |
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. |