java.lang.Object
com.google.cloud.firestore.pipeline.expressions.Expression
Direct Known Subclasses:
BooleanExpression, Field, FunctionExpression, PipelineValueExpression

public abstract class Expression extends Object
Represents an expression that can be evaluated to a value within the execution of a Pipeline.

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

  • **Field references:** Access values from document fields.
  • **Literals:** Represent constant values (strings, numbers, booleans).
  • **Function calls:** Apply functions to one or more expressions.

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

  • Method Details

    • constant

      public static Expression constant(String value)
      Create a constant for a String value.
      Parameters:
      value - The String value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(Number value)
      Create a constant for a Number value.
      Parameters:
      value - The Number value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(Date value)
      Create a constant for a Date value.
      Parameters:
      value - The Date value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(com.google.cloud.Timestamp value)
      Create a constant for a Timestamp value.
      Parameters:
      value - The Timestamp value.
      Returns:
      A new Expression constant instance.
    • constant

      public static BooleanExpression constant(Boolean value)
      Create a constant for a Boolean value.
      Parameters:
      value - The Boolean value.
      Returns:
      A new BooleanExpression constant instance.
    • constant

      public static Expression constant(GeoPoint value)
      Create a constant for a GeoPoint value.
      Parameters:
      value - The GeoPoint value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(Blob value)
      Create a constant for a Blob value.
      Parameters:
      value - The Blob value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(DocumentReference value)
      Create a constant for a DocumentReference value.
      Parameters:
      value - The DocumentReference value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(byte[] value)
      Create a constant for a bytes value.
      Parameters:
      value - The bytes value.
      Returns:
      A new Expression constant instance.
    • constant

      public static Expression constant(VectorValue value)
      Create a constant for a VectorValue value.
      Parameters:
      value - The VectorValue value.
      Returns:
      A new Expression constant instance.
    • nullValue

      public static Expression nullValue()
      Constant for a null value.
      Returns:
      An Expression constant instance.
    • field

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

      Parameters:
      path - The path to the field.
      Returns:
      A new Field instance representing the specified path.
    • field

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

      Parameters:
      fieldPath - The FieldPath to the field.
      Returns:
      A new Field instance representing the specified path.
    • currentTimestamp

      public static Expression currentTimestamp()
      Creates an expression that returns the current timestamp.
      Returns:
      A new Expression representing the current timestamp.
    • ifAbsent

      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:
      ifExpr - The expression to check.
      elseExpr - The default value.
      Returns:
      A new Expression representing the ifAbsent operation.
    • ifAbsent

      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:
      ifExpr - The expression to check.
      elseValue - The default value.
      Returns:
      A new Expression representing the ifAbsent operation.
    • ifAbsent

      public static Expression ifAbsent(String ifFieldName, Expression elseExpr)
      Creates an expression that returns a default value if a field is absent.
      Parameters:
      ifFieldName - The field to check.
      elseExpr - The default value.
      Returns:
      A new Expression representing the ifAbsent operation.
    • ifAbsent

      public static Expression ifAbsent(String ifFieldName, Object elseValue)
      Creates an expression that returns a default value if a field is absent.
      Parameters:
      ifFieldName - The field to check.
      elseValue - The default value.
      Returns:
      A new Expression representing the ifAbsent operation.
    • ifNull

      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(com.google.cloud.firestore.pipeline.expressions.Expression,com.google.cloud.firestore.pipeline.expressions.Expression) only triggers for missing fields.

      Parameters:
      ifExpr - The expression to check.
      elseExpression - The default expression that will be evaluated and returned.
      Returns:
      A new Expression representing the ifNull operation.
    • ifNull

      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(com.google.cloud.firestore.pipeline.expressions.Expression,com.google.cloud.firestore.pipeline.expressions.Expression) only triggers for missing fields.

      Parameters:
      ifExpr - The expression to check.
      elseValue - The default value that will be returned.
      Returns:
      A new Expression representing the ifNull operation.
    • ifNull

      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(com.google.cloud.firestore.pipeline.expressions.Expression,com.google.cloud.firestore.pipeline.expressions.Expression) only triggers for missing fields.

      Parameters:
      ifFieldName - The field to check.
      elseExpression - The default expression that will be evaluated and returned.
      Returns:
      A new Expression representing the ifNull operation.
    • ifNull

      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(com.google.cloud.firestore.pipeline.expressions.Expression,com.google.cloud.firestore.pipeline.expressions.Expression) only triggers for missing fields.

      Parameters:
      ifFieldName - The field to check.
      elseValue - The default value that will be returned.
      Returns:
      A new Expression representing the ifNull operation.
    • coalesce

      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:
      expression - The first expression to check for null.
      replacement - The fallback expression or value if the first one is null.
      others - Optional additional expressions to check if previous ones are null.
      Returns:
      A new Expression representing the coalesce operation.
    • coalesce

      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:
      firstFieldName - The name of the first field to check for null.
      replacement - The fallback expression or value if the first one is null.
      others - Optional additional expressions to check if previous ones are null.
      Returns:
      A new Expression representing the coalesce operation.
    • join

      public static Expression join(Expression arrayExpression, String delimiter)
      Creates an expression that joins the elements of an array into a string.
      Parameters:
      arrayExpression - The expression representing the array.
      delimiter - The delimiter to use.
      Returns:
      A new Expression representing the join operation.
    • join

      public static Expression join(Expression arrayExpression, Expression delimiterExpression)
      Creates an expression that joins the elements of an array into a string.
      Parameters:
      arrayExpression - The expression representing the array.
      delimiterExpression - The expression representing the delimiter.
      Returns:
      A new Expression representing the join operation.
    • join

      public static Expression join(String arrayFieldName, String delimiter)
      Creates an expression that joins the elements of an array into a string.
      Parameters:
      arrayFieldName - The field name of the array.
      delimiter - The delimiter to use.
      Returns:
      A new Expression representing the join operation.
    • join

      public static Expression join(String arrayFieldName, Expression delimiterExpression)
      Creates an expression that joins the elements of an array into a string.
      Parameters:
      arrayFieldName - The field name of the array.
      delimiterExpression - The expression representing the delimiter.
      Returns:
      A new Expression representing the join operation.
    • rawExpression

      public static Expression rawExpression(String name, Expression... expr)
      Creates a generic function expression that is not yet implemented.
      Parameters:
      name - The name of the generic function.
      expr - The expressions to be passed as arguments to the function.
      Returns:
      A new Expression representing the generic function.
    • and

      public static BooleanExpression and(BooleanExpression condition, BooleanExpression... conditions)
      Creates an expression that performs a logical 'AND' operation.
      Parameters:
      condition - The first BooleanExpression.
      conditions - Additional BooleanExpressions.
      Returns:
      A new BooleanExpression representing the logical 'AND' operation.
    • or

      public static BooleanExpression or(BooleanExpression condition, BooleanExpression... conditions)
      Creates an expression that performs a logical 'OR' operation.
      Parameters:
      condition - The first BooleanExpression.
      conditions - Additional BooleanExpressions.
      Returns:
      A new BooleanExpression representing the logical 'OR' operation.
    • nor

      public static BooleanExpression nor(BooleanExpression condition, BooleanExpression... conditions)
      Creates an expression that performs a logical 'NOR' operation.
      Parameters:
      condition - The first BooleanExpression.
      conditions - Additional BooleanExpressions.
      Returns:
      A new BooleanExpression representing the logical 'NOR' operation.
    • switchOn

      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:
      condition - The first BooleanExpression.
      result - The result if the first condition is true.
      others - Additional conditions and results, and optionally a default value.
      Returns:
      A new Expression representing the switchOn operation.
    • xor

      public static BooleanExpression xor(BooleanExpression condition, BooleanExpression... conditions)
      Creates an expression that performs a logical 'XOR' operation.
      Parameters:
      condition - The first BooleanExpression.
      conditions - Additional BooleanExpressions.
      Returns:
      A new BooleanExpression representing the logical 'XOR' operation.
    • not

      public static BooleanExpression not(BooleanExpression condition)
      Creates an expression that negates a boolean expression.
      Parameters:
      condition - The boolean expression to negate.
      Returns:
      A new BooleanExpression representing the not operation.
    • add

      public static Expression add(Expression first, Expression second)
      Creates an expression that adds numeric expressions.
      Parameters:
      first - Numeric expression to add.
      second - Numeric expression to add.
      Returns:
      A new Expression representing the addition operation.
    • add

      public static Expression add(Expression first, Number second)
      Creates an expression that adds numeric expressions with a constant.
      Parameters:
      first - Numeric expression to add.
      second - Constant to add.
      Returns:
      A new Expression representing the addition operation.
    • add

      public static Expression add(String fieldName, Expression second)
      Creates an expression that adds a numeric field with a numeric expression.
      Parameters:
      fieldName - Numeric field to add.
      second - Numeric expression to add to field value.
      Returns:
      A new Expression representing the addition operation.
    • add

      public static Expression add(String fieldName, Number second)
      Creates an expression that adds a numeric field with constant.
      Parameters:
      fieldName - Numeric field to add.
      second - Constant to add.
      Returns:
      A new Expression representing the addition operation.
    • subtract

      public static Expression subtract(Expression minuend, Expression subtrahend)
      Creates an expression that subtracts two expressions.
      Parameters:
      minuend - Numeric expression to subtract from.
      subtrahend - Numeric expression to subtract.
      Returns:
      A new Expression representing the subtract operation.
    • subtract

      public static Expression subtract(Expression minuend, Number subtrahend)
      Creates an expression that subtracts a constant value from a numeric expression.
      Parameters:
      minuend - Numeric expression to subtract from.
      subtrahend - Constant to subtract.
      Returns:
      A new Expression representing the subtract operation.
    • subtract

      public static Expression subtract(String fieldName, Expression subtrahend)
      Creates an expression that subtracts a numeric expressions from numeric field.
      Parameters:
      fieldName - Numeric field to subtract from.
      subtrahend - Numeric expression to subtract.
      Returns:
      A new Expression representing the subtract operation.
    • subtract

      public static Expression subtract(String fieldName, Number subtrahend)
      Creates an expression that subtracts a constant from numeric field.
      Parameters:
      fieldName - Numeric field to subtract from.
      subtrahend - Constant to subtract.
      Returns:
      A new Expression representing the subtract operation.
    • multiply

      public static Expression multiply(Expression first, Expression second)
      Creates an expression that multiplies numeric expressions.
      Parameters:
      first - Numeric expression to multiply.
      second - Numeric expression to multiply.
      Returns:
      A new Expression representing the multiplication operation.
    • multiply

      public static Expression multiply(Expression first, Number second)
      Creates an expression that multiplies numeric expressions with a constant.
      Parameters:
      first - Numeric expression to multiply.
      second - Constant to multiply.
      Returns:
      A new Expression representing the multiplication operation.
    • multiply

      public static Expression multiply(String fieldName, Expression second)
      Creates an expression that multiplies a numeric field with a numeric expression.
      Parameters:
      fieldName - Numeric field to multiply.
      second - Numeric expression to multiply.
      Returns:
      A new Expression representing the multiplication operation.
    • multiply

      public static Expression multiply(String fieldName, Number second)
      Creates an expression that multiplies a numeric field with a constant.
      Parameters:
      fieldName - Numeric field to multiply.
      second - Constant to multiply.
      Returns:
      A new Expression representing the multiplication operation.
    • divide

      public static Expression divide(Expression dividend, Expression divisor)
      Creates an expression that divides two numeric expressions.
      Parameters:
      dividend - The numeric expression to be divided.
      divisor - The numeric expression to divide by.
      Returns:
      A new Expression representing the division operation.
    • divide

      public static Expression divide(Expression dividend, Number divisor)
      Creates an expression that divides a numeric expression by a constant.
      Parameters:
      dividend - The numeric expression to be divided.
      divisor - The constant to divide by.
      Returns:
      A new Expression representing the division operation.
    • divide

      public static Expression divide(String fieldName, Expression divisor)
      Creates an expression that divides numeric field by a numeric expression.
      Parameters:
      fieldName - The numeric field name to be divided.
      divisor - The numeric expression to divide by.
      Returns:
      A new Expression representing the divide operation.
    • divide

      public static Expression divide(String fieldName, Number divisor)
      Creates an expression that divides a numeric field by a constant.
      Parameters:
      fieldName - The numeric field name to be divided.
      divisor - The constant to divide by.
      Returns:
      A new Expression representing the divide operation.
    • mod

      public static Expression mod(Expression dividend, Expression divisor)
      Creates an expression that calculates the modulo (remainder) of dividing two numeric expressions.
      Parameters:
      dividend - The numeric expression to be divided.
      divisor - The numeric expression to divide by.
      Returns:
      A new Expression representing the modulo operation.
    • mod

      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:
      dividend - The numeric expression to be divided.
      divisor - The constant to divide by.
      Returns:
      A new Expression representing the modulo operation.
    • mod

      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:
      fieldName - The numeric field name to be divided.
      divisor - The numeric expression to divide by.
      Returns:
      A new Expression representing the modulo operation.
    • mod

      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:
      fieldName - The numeric field name to be divided.
      divisor - The constant to divide by.
      Returns:
      A new Expression representing the modulo operation.
    • equal

      public static BooleanExpression equal(Expression left, Expression right)
      Creates an expression that checks if two expressions are equal.
      Parameters:
      left - The first expression.
      right - The second expression.
      Returns:
      A new BooleanExpression representing the equality comparison.
    • equal

      public static BooleanExpression equal(Expression left, Object right)
      Creates an expression that checks if an expression is equal to a constant value.
      Parameters:
      left - The expression.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the equality comparison.
    • equal

      public static BooleanExpression equal(String fieldName, Expression right)
      Creates an expression that checks if a field is equal to an expression.
      Parameters:
      fieldName - The field name.
      right - The expression.
      Returns:
      A new BooleanExpression representing the equality comparison.
    • equal

      public static BooleanExpression equal(String fieldName, Object right)
      Creates an expression that checks if a field is equal to a constant value.
      Parameters:
      fieldName - The field name.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the equality comparison.
    • notEqual

      public static BooleanExpression notEqual(Expression left, Expression right)
      Creates an expression that checks if two expressions are not equal.
      Parameters:
      left - The first expression.
      right - The second expression.
      Returns:
      A new BooleanExpression representing the inequality comparison.
    • notEqual

      public static BooleanExpression notEqual(Expression left, Object right)
      Creates an expression that checks if an expression is not equal to a constant value.
      Parameters:
      left - The expression.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the inequality comparison.
    • notEqual

      public static BooleanExpression notEqual(String fieldName, Expression right)
      Creates an expression that checks if a field is not equal to an expression.
      Parameters:
      fieldName - The field name.
      right - The expression.
      Returns:
      A new BooleanExpression representing the inequality comparison.
    • notEqual

      public static BooleanExpression notEqual(String fieldName, Object right)
      Creates an expression that checks if a field is not equal to a constant value.
      Parameters:
      fieldName - The field name.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the inequality comparison.
    • greaterThan

      public static BooleanExpression greaterThan(Expression left, Expression right)
      Creates an expression that checks if the first expression is greater than the second expression.
      Parameters:
      left - The first expression.
      right - The second expression.
      Returns:
      A new BooleanExpression representing the greater than comparison.
    • greaterThan

      public static BooleanExpression greaterThan(Expression left, Object right)
      Creates an expression that checks if an expression is greater than a constant value.
      Parameters:
      left - The expression.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the greater than comparison.
    • greaterThan

      public static BooleanExpression greaterThan(String fieldName, Expression right)
      Creates an expression that checks if a field is greater than an expression.
      Parameters:
      fieldName - The field name.
      right - The expression.
      Returns:
      A new BooleanExpression representing the greater than comparison.
    • greaterThan

      public static BooleanExpression greaterThan(String fieldName, Object right)
      Creates an expression that checks if a field is greater than a constant value.
      Parameters:
      fieldName - The field name.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the greater than comparison.
    • greaterThanOrEqual

      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:
      left - The first expression.
      right - The second expression.
      Returns:
      A new BooleanExpression representing the greater than or equal to comparison.
    • greaterThanOrEqual

      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:
      left - The expression.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the greater than or equal to comparison.
    • greaterThanOrEqual

      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:
      fieldName - The field name.
      right - The expression.
      Returns:
      A new BooleanExpression representing the greater than or equal to comparison.
    • greaterThanOrEqual

      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:
      fieldName - The field name.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the greater than or equal to comparison.
    • lessThan

      public static BooleanExpression lessThan(Expression left, Expression right)
      Creates an expression that checks if the first expression is less than the second expression.
      Parameters:
      left - The first expression.
      right - The second expression.
      Returns:
      A new BooleanExpression representing the less than comparison.
    • lessThan

      public static BooleanExpression lessThan(Expression left, Object right)
      Creates an expression that checks if an expression is less than a constant value.
      Parameters:
      left - The expression.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the less than comparison.
    • lessThan

      public static BooleanExpression lessThan(String fieldName, Expression right)
      Creates an expression that checks if a field is less than an expression.
      Parameters:
      fieldName - The field name.
      right - The expression.
      Returns:
      A new BooleanExpression representing the less than comparison.
    • lessThan

      public static BooleanExpression lessThan(String fieldName, Object right)
      Creates an expression that checks if a field is less than a constant value.
      Parameters:
      fieldName - The field name.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the less than comparison.
    • lessThanOrEqual

      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:
      left - The first expression.
      right - The second expression.
      Returns:
      A new BooleanExpression representing the less than or equal to comparison.
    • lessThanOrEqual

      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:
      left - The expression.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the less than or equal to comparison.
    • lessThanOrEqual

      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:
      fieldName - The field name.
      right - The expression.
      Returns:
      A new BooleanExpression representing the less than or equal to comparison.
    • lessThanOrEqual

      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:
      fieldName - The field name.
      right - The constant value.
      Returns:
      A new BooleanExpression representing the less than or equal to comparison.
    • equalAny

      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:
      expression - The expression whose results to compare.
      values - The values to check against.
      Returns:
      A new BooleanExpression representing the 'IN' comparison.
    • equalAny

      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:
      expression - The expression whose results to compare.
      arrayExpression - An expression that evaluates to an array, whose elements to check for equality to the input.
      Returns:
      A new BooleanExpression representing the 'IN' comparison.
    • equalAny

      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:
      fieldName - The field to compare.
      values - The values to check against.
      Returns:
      A new BooleanExpression representing the 'IN' comparison.
    • equalAny

      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:
      fieldName - The field to compare.
      arrayExpression - An expression that evaluates to an array, whose elements to check for equality to the input.
      Returns:
      A new BooleanExpression representing the 'IN' comparison.
    • notEqualAny

      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:
      expression - The expression whose results to compare.
      values - The values to check against.
      Returns:
      A new BooleanExpression representing the 'NOT IN' comparison.
    • notEqualAny

      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:
      expression - The expression whose results to compare.
      arrayExpression - An expression that evaluates to an array, whose elements to check for equality to the input.
      Returns:
      A new BooleanExpression representing the 'NOT IN' comparison.
    • notEqualAny

      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:
      fieldName - The field to compare.
      values - The values to check against.
      Returns:
      A new BooleanExpression representing the 'NOT IN' comparison.
    • notEqualAny

      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:
      fieldName - The field to compare.
      arrayExpression - An expression that evaluates to an array, whose elements to check for equality to the input.
      Returns:
      A new BooleanExpression representing the 'NOT IN' comparison.
    • charLength

      public static Expression charLength(Expression string)
      Creates an expression that calculates the character length of a string expression in UTF8.
      Parameters:
      string - The expression representing the string.
      Returns:
      A new Expression representing the charLength operation.
    • charLength

      public static Expression charLength(String fieldName)
      Creates an expression that calculates the character length of a string field in UTF8.
      Parameters:
      fieldName - The name of the field containing the string.
      Returns:
      A new Expression representing the charLength operation.
    • byteLength

      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.
      Parameters:
      string - The expression representing the string.
      Returns:
      A new Expression representing the length of the string in bytes.
    • byteLength

      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.
      Parameters:
      fieldName - The name of the field containing the string.
      Returns:
      A new Expression representing the length of the string in bytes.
    • length

      public static Expression length(Expression string)
      Creates an expression that calculates the length of string, array, map, vector, or Blob.
      Parameters:
      string - The expression representing the value to calculate the length of.
      Returns:
      A new Expression representing the length of the value.
    • length

      public static Expression length(String fieldName)
      Creates an expression that calculates the length of string, array, map, vector, or Blob.
      Parameters:
      fieldName - The name of the field containing the value.
      Returns:
      A new Expression representing the length of the value.
    • like

      public static BooleanExpression like(Expression string, Expression pattern)
      Creates an expression that performs a case-sensitive wildcard string comparison.
      Parameters:
      string - The expression representing the string to perform the comparison on.
      pattern - The pattern to search for. You can use "%" as a wildcard character.
      Returns:
      A new BooleanExpression representing the like operation.
    • like

      public static BooleanExpression like(Expression string, String pattern)
      Creates an expression that performs a case-sensitive wildcard string comparison.
      Parameters:
      string - The expression representing the string to perform the comparison on.
      pattern - The pattern to search for. You can use "%" as a wildcard character.
      Returns:
      A new BooleanExpression representing the like operation.
    • like

      public static BooleanExpression like(String fieldName, Expression pattern)
      Creates an expression that performs a case-sensitive wildcard string comparison against a field.
      Parameters:
      fieldName - The name of the field containing the string.
      pattern - The pattern to search for. You can use "%" as a wildcard character.
      Returns:
      A new BooleanExpression representing the like comparison.
    • like

      public static BooleanExpression like(String fieldName, String pattern)
      Creates an expression that performs a case-sensitive wildcard string comparison against a field.
      Parameters:
      fieldName - The name of the field containing the string.
      pattern - The pattern to search for. You can use "%" as a wildcard character.
      Returns:
      A new BooleanExpression representing the like comparison.
    • regexContains

      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:
      string - The expression representing the string to perform the comparison on.
      pattern - The regular expression to use for the search.
      Returns:
      A new BooleanExpression representing the contains regular expression comparison.
    • regexContains

      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:
      string - The expression representing the string to perform the comparison on.
      pattern - The regular expression to use for the search.
      Returns:
      A new BooleanExpression representing the contains regular expression comparison.
    • regexContains

      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:
      fieldName - The name of the field containing the string.
      pattern - The regular expression to use for the search.
      Returns:
      A new BooleanExpression representing the contains regular expression comparison.
    • regexContains

      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:
      fieldName - The name of the field containing the string.
      pattern - The regular expression to use for the search.
      Returns:
      A new BooleanExpression representing the contains regular expression comparison.
    • regexFind

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      string - The expression representing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression representing the regular expression find function.
    • regexFind

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      string - The expression representing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression representing the regular expression find function.
    • regexFind

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      fieldName - The name of the field containing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression representing the regular expression find function.
    • regexFind

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      fieldName - The name of the field containing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression representing the regular expression find function.
    • regexFindAll

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      string - The expression representing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression that evaluates to a list of matched substrings.
    • regexFindAll

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      string - The expression representing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression that evaluates to a list of matched substrings.
    • regexFindAll

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      fieldName - The name of the field containing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression that evaluates to a list of matched substrings.
    • regexFindAll

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      fieldName - The name of the field containing the string to search.
      pattern - The regular expression to search for.
      Returns:
      A new Expression that evaluates to a list of matched substrings.
    • regexMatch

      public static BooleanExpression regexMatch(Expression string, Expression pattern)
      Creates an expression that checks if a string field matches a specified regular expression.
      Parameters:
      string - The expression representing the string to match against.
      pattern - The regular expression to use for the match.
      Returns:
      A new BooleanExpression representing the regular expression match comparison.
    • regexMatch

      public static BooleanExpression regexMatch(Expression string, String pattern)
      Creates an expression that checks if a string field matches a specified regular expression.
      Parameters:
      string - The expression representing the string to match against.
      pattern - The regular expression to use for the match.
      Returns:
      A new BooleanExpression representing the regular expression match comparison.
    • regexMatch

      public static BooleanExpression regexMatch(String fieldName, Expression pattern)
      Creates an expression that checks if a string field matches a specified regular expression.
      Parameters:
      fieldName - The name of the field containing the string.
      pattern - The regular expression to use for the match.
      Returns:
      A new BooleanExpression representing the regular expression match comparison.
    • regexMatch

      public static BooleanExpression regexMatch(String fieldName, String pattern)
      Creates an expression that checks if a string field matches a specified regular expression.
      Parameters:
      fieldName - The name of the field containing the string.
      pattern - The regular expression to use for the match.
      Returns:
      A new BooleanExpression representing the regular expression match comparison.
    • stringContains

      public static BooleanExpression stringContains(Expression string, Expression substring)
      Creates an expression that checks if a string expression contains a specified substring.
      Parameters:
      string - The expression representing the string to perform the comparison on.
      substring - The expression representing the substring to search for.
      Returns:
      A new BooleanExpression representing the contains comparison.
    • stringContains

      public static BooleanExpression stringContains(Expression string, String substring)
      Creates an expression that checks if a string expression contains a specified substring.
      Parameters:
      string - The expression representing the string to perform the comparison on.
      substring - The substring to search for.
      Returns:
      A new BooleanExpression representing the contains comparison.
    • stringContains

      public static BooleanExpression stringContains(String fieldName, Expression substring)
      Creates an expression that checks if a string field contains a specified substring.
      Parameters:
      fieldName - The name of the field to perform the comparison on.
      substring - The expression representing the substring to search for.
      Returns:
      A new BooleanExpression representing the contains comparison.
    • stringContains

      public static BooleanExpression stringContains(String fieldName, String substring)
      Creates an expression that checks if a string field contains a specified substring.
      Parameters:
      fieldName - The name of the field to perform the comparison on.
      substring - The substring to search for.
      Returns:
      A new BooleanExpression representing the contains comparison.
    • startsWith

      public static BooleanExpression startsWith(Expression string, Expression prefix)
      Creates an expression that checks if a string expression starts with a given prefix.
      Parameters:
      string - The expression to check.
      prefix - The prefix string expression to check for.
      Returns:
      A new BooleanExpression representing the 'starts with' comparison.
    • startsWith

      public static BooleanExpression startsWith(Expression string, String prefix)
      Creates an expression that checks if a string expression starts with a given prefix.
      Parameters:
      string - The expression to check.
      prefix - The prefix string to check for.
      Returns:
      A new BooleanExpression representing the 'starts with' comparison.
    • startsWith

      public static BooleanExpression startsWith(String fieldName, Expression prefix)
      Creates an expression that checks if a string expression starts with a given prefix.
      Parameters:
      fieldName - The name of field that contains a string to check.
      prefix - The prefix string expression to check for.
      Returns:
      A new BooleanExpression representing the 'starts with' comparison.
    • startsWith

      public static BooleanExpression startsWith(String fieldName, String prefix)
      Creates an expression that checks if a string expression starts with a given prefix.
      Parameters:
      fieldName - The name of field that contains a string to check.
      prefix - The prefix string to check for.
      Returns:
      A new BooleanExpression representing the 'starts with' comparison.
    • endsWith

      public static BooleanExpression endsWith(Expression string, Expression suffix)
      Creates an expression that checks if a string expression ends with a given suffix.
      Parameters:
      string - The expression to check.
      suffix - The suffix string expression to check for.
      Returns:
      A new BooleanExpression representing the 'ends with' comparison.
    • endsWith

      public static BooleanExpression endsWith(Expression string, String suffix)
      Creates an expression that checks if a string expression ends with a given suffix.
      Parameters:
      string - The expression to check.
      suffix - The suffix string to check for.
      Returns:
      A new BooleanExpression representing the 'ends with' comparison.
    • endsWith

      public static BooleanExpression endsWith(String fieldName, Expression suffix)
      Creates an expression that checks if a string expression ends with a given suffix.
      Parameters:
      fieldName - The name of field that contains a string to check.
      suffix - The suffix string expression to check for.
      Returns:
      A new BooleanExpression representing the 'ends with' comparison.
    • endsWith

      public static BooleanExpression endsWith(String fieldName, String suffix)
      Creates an expression that checks if a string expression ends with a given suffix.
      Parameters:
      fieldName - The name of field that contains a string to check.
      suffix - The suffix string to check for.
      Returns:
      A new BooleanExpression representing the 'ends with' comparison.
    • substring

      public static Expression substring(Expression string, Expression index, Expression length)
      Creates an expression that returns a substring of the given string.
      Parameters:
      string - The expression representing the string to get a substring from.
      index - The starting index of the substring.
      length - The length of the substring.
      Returns:
      A new Expression representing the substring.
    • substring

      public static Expression substring(String fieldName, int index, int length)
      Creates an expression that returns a substring of the given string.
      Parameters:
      fieldName - The name of the field containing the string to get a substring from.
      index - The starting index of the substring.
      length - The length of the substring.
      Returns:
      A new Expression representing the substring.
    • toLower

      public static Expression toLower(Expression string)
      Creates an expression that converts a string expression to lowercase.
      Parameters:
      string - The expression representing the string to convert to lowercase.
      Returns:
      A new Expression representing the lowercase string.
    • toLower

      public static Expression toLower(String fieldName)
      Creates an expression that converts a string field to lowercase.
      Parameters:
      fieldName - The name of the field containing the string to convert to lowercase.
      Returns:
      A new Expression representing the lowercase string.
    • toUpper

      public static Expression toUpper(Expression string)
      Creates an expression that converts a string expression to uppercase.
      Parameters:
      string - The expression representing the string to convert to uppercase.
      Returns:
      A new Expression representing the lowercase string.
    • toUpper

      public static Expression toUpper(String fieldName)
      Creates an expression that converts a string field to uppercase.
      Parameters:
      fieldName - The name of the field containing the string to convert to uppercase.
      Returns:
      A new Expression representing the lowercase string.
    • trim

      public static Expression trim(Expression string)
      Creates an expression that removes leading and trailing whitespace from a string expression.
      Parameters:
      string - The expression representing the string to trim.
      Returns:
      A new Expression representing the trimmed string.
    • trim

      public static Expression trim(String fieldName)
      Creates an expression that removes leading and trailing whitespace from a string field.
      Parameters:
      fieldName - The name of the field containing the string to trim.
      Returns:
      A new Expression representing the trimmed string.
    • trimValue

      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:
      value - The expression representing the string or blob to trim.
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • trimValue

      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:
      fieldName - The name of the field containing the string or blob to trim.
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • trimValue

      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:
      value - The expression representing the string or blob to trim.
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • trimValue

      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:
      fieldName - The name of the field containing the string or blob to trim.
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrim

      public static Expression ltrim(Expression value)
      Creates an expression that removes whitespace from the beginning of a string or blob.
      Parameters:
      value - The expression representing the string or blob to trim.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrim

      public static Expression ltrim(String fieldName)
      Creates an expression that removes whitespace from the beginning of a string or blob.
      Parameters:
      fieldName - The name of the field containing the string or blob to trim.
      Returns:
      A new Expression representing the trimmed string.
    • ltrimValue

      public static Expression ltrimValue(Expression value, String characters)
      Creates an expression that removes specified characters from the beginning of a string or blob.
      Parameters:
      value - The expression representing the string or blob to trim.
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrimValue

      public static Expression ltrimValue(String fieldName, String characters)
      Creates an expression that removes specified characters from the beginning of a string or blob.
      Parameters:
      fieldName - The name of the field containing the string or blob to trim.
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrimValue

      public static Expression ltrimValue(Expression value, Expression characters)
      Creates an expression that removes specified characters from the beginning of a string or blob.
      Parameters:
      value - The expression representing the string or blob to trim.
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrimValue

      public static Expression ltrimValue(String fieldName, Expression characters)
      Creates an expression that removes specified characters from the beginning of a string or blob.
      Parameters:
      fieldName - The name of the field containing the string or blob to trim.
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrim

      public static Expression rtrim(Expression value)
      Creates an expression that removes whitespace from the end of a string or blob.
      Parameters:
      value - The expression representing the string or blob to trim.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrim

      public static Expression rtrim(String fieldName)
      Creates an expression that removes whitespace from the end of a string or blob.
      Parameters:
      fieldName - The name of the field containing the string to trim.
      Returns:
      A new Expression representing the trimmed string.
    • rtrimValue

      public static Expression rtrimValue(Expression value, String characters)
      Creates an expression that removes specified characters from the end of a string or blob.
      Parameters:
      value - The expression representing the string or blob to trim.
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrimValue

      public static Expression rtrimValue(String fieldName, String characters)
      Creates an expression that removes specified characters from the end of a string or blob.
      Parameters:
      fieldName - The name of the field containing the string or blob to trim.
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrimValue

      public static Expression rtrimValue(Expression value, Expression characters)
      Creates an expression that removes specified characters from the end of a string or blob.
      Parameters:
      value - The expression representing the string or blob to trim.
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrimValue

      public static Expression rtrimValue(String fieldName, Expression characters)
      Creates an expression that removes specified characters from the end of a string or blob.
      Parameters:
      fieldName - The name of the field containing the string or blob to trim.
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • stringRepeat

      public static Expression stringRepeat(Expression value, Number repetitions)
      Creates an expression that repeats a string or blob a specified number of times.
      Parameters:
      value - The expression representing the string or blob to repeat.
      repetitions - The number of times to repeat the string or blob.
      Returns:
      A new Expression representing the repeated string or blob.
    • stringRepeat

      public static Expression stringRepeat(String fieldName, Number repetitions)
      Creates an expression that repeats a string or blob a specified number of times.
      Parameters:
      fieldName - The name of the field containing the string or blob to repeat.
      repetitions - The number of times to repeat the string or blob.
      Returns:
      A new Expression representing the repeated string or blob.
    • stringRepeat

      public static Expression stringRepeat(Expression value, Expression repetitions)
      Creates an expression that repeats a string or blob a specified number of times.
      Parameters:
      value - The expression representing the string or blob to repeat.
      repetitions - The expression representing the number of times to repeat.
      Returns:
      A new Expression representing the repeated string or blob.
    • stringRepeat

      public static Expression stringRepeat(String fieldName, Expression repetitions)
      Creates an expression that repeats a string or blob a specified number of times.
      Parameters:
      fieldName - The name of the field containing the string or blob to repeat.
      repetitions - The expression representing the number of times to repeat.
      Returns:
      A new Expression representing the repeated string or blob.
    • stringReplaceAll

      public static Expression stringReplaceAll(Expression value, String find, String replacement)
      Creates an expression that replaces all occurrences of a substring or byte sequence.
      Parameters:
      value - The expression representing the input string or blob.
      find - The match pattern.
      replacement - The replacement string/bytes.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceAll

      public static Expression stringReplaceAll(String fieldName, String find, String replacement)
      Creates an expression that replaces all occurrences of a substring or byte sequence.
      Parameters:
      fieldName - The name of the field containing the input string or blob.
      find - The match pattern.
      replacement - The replacement string/bytes.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceAll

      public static Expression stringReplaceAll(Expression value, Expression find, Expression replacement)
      Creates an expression that replaces all occurrences of a substring or byte sequence.
      Parameters:
      value - The expression representing the input string or blob.
      find - The expression representing the match pattern.
      replacement - The expression representing the replacement value.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceAll

      public static Expression stringReplaceAll(String fieldName, Expression find, Expression replacement)
      Creates an expression that replaces all occurrences of a substring or byte sequence.
      Parameters:
      fieldName - The name of the field containing the input string or blob.
      find - The expression representing the match pattern.
      replacement - The expression representing the replacement value.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceOne

      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:
      value - The expression representing the input string or blob.
      find - The match pattern.
      replacement - The replacement string/bytes.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceOne

      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:
      fieldName - The name of the field containing the input string or blob.
      find - The match pattern.
      replacement - The replacement string/bytes.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceOne

      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:
      value - The expression representing the input string or blob.
      find - The expression representing the match pattern.
      replacement - The expression representing the replacement value.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceOne

      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:
      fieldName - The name of the field containing the input string or blob.
      find - The expression representing the match pattern.
      replacement - The expression representing the replacement value.
      Returns:
      A new Expression representing the replaced value.
    • stringIndexOf

      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:
      value - The expression representing the input string or blob.
      search - The search pattern.
      Returns:
      A new Expression representing the index.
    • stringIndexOf

      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:
      fieldName - The name of the field containing the input string or blob.
      search - The search pattern.
      Returns:
      A new Expression representing the index.
    • stringIndexOf

      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:
      value - The expression representing the input string or blob.
      search - The expression representing the search pattern.
      Returns:
      A new Expression representing the index.
    • stringIndexOf

      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:
      fieldName - The name of the field containing the input string or blob.
      search - The expression representing the search pattern.
      Returns:
      A new Expression representing the index.
    • split

      public static Expression split(Expression value, Expression delimiter)
      Creates an expression that splits a string or blob by a delimiter.
      Parameters:
      value - The expression representing the string or blob to split.
      delimiter - The delimiter to split by.
      Returns:
      A new Expression representing the split string or blob as an array.
    • split

      public static Expression split(Expression value, String delimiter)
      Creates an expression that splits a string or blob by a delimiter.
      Parameters:
      value - The expression representing the string or blob to split.
      delimiter - The delimiter to split by.
      Returns:
      A new Expression representing the split string or blob as an array.
    • split

      public static Expression split(String fieldName, Expression delimiter)
      Creates an expression that splits a string or blob by a delimiter.
      Parameters:
      fieldName - The name of the field containing the string or blob to split.
      delimiter - The delimiter to split by.
      Returns:
      A new Expression representing the split string or blob as an array.
    • split

      public static Expression split(String fieldName, String delimiter)
      Creates an expression that splits a string or blob by a delimiter.
      Parameters:
      fieldName - The name of the field containing the string or blob to split.
      delimiter - The delimiter to split by.
      Returns:
      A new Expression representing the split string or blob as an array.
    • stringConcat

      public static Expression stringConcat(Expression firstString, Object... otherStrings)
      Creates an expression that concatenates string expressions together.
      Parameters:
      firstString - The expression representing the initial string value.
      otherStrings - Optional additional string expressions or string constants to concatenate.
      Returns:
      A new Expression representing the concatenated string.
    • stringConcat

      public static Expression stringConcat(String fieldName, Object... otherStrings)
      Creates an expression that concatenates string expressions together.
      Parameters:
      fieldName - The field name containing the initial string value.
      otherStrings - Optional additional string expressions or string constants to concatenate.
      Returns:
      A new Expression representing the concatenated string.
    • concat

      public static Expression concat(Expression first, Object... others)
      Creates an expression that concatenates expressions together.
      Parameters:
      first - The expression representing the initial value.
      others - Optional additional expressions or constants to concatenate.
      Returns:
      A new Expression representing the concatenated value.
    • concat

      public static Expression concat(String fieldName, Object... others)
      Creates an expression that concatenates expressions together.
      Parameters:
      fieldName - The field name containing the initial value.
      others - Optional additional expressions or constants to concatenate.
      Returns:
      A new Expression representing the concatenated value.
    • map

      public static Expression map(Map<String,Object> elements)
      Creates an expression that creates a Firestore map value from an input object.
      Parameters:
      elements - The input map to evaluate in the expression.
      Returns:
      A new Expression representing the map function.
    • mapGet

      public static Expression mapGet(Expression map, Expression key)
      Accesses a value from a map (object) field using the provided keyExpression.
      Parameters:
      map - The expression representing the map.
      key - The key to access in the map.
      Returns:
      A new Expression representing the value associated with the given key in the map.
    • mapGet

      public static Expression mapGet(Expression map, String key)
      Accesses a value from a map (object) field using the provided key.
      Parameters:
      map - The expression representing the map.
      key - The key to access in the map.
      Returns:
      A new Expression representing the value associated with the given key in the map.
    • mapGet

      public static Expression mapGet(String fieldName, String key)
      Accesses a value from a map (object) field using the provided key.
      Parameters:
      fieldName - The field name of the map field.
      key - The key to access in the map.
      Returns:
      A new Expression representing the value associated with the given key in the map.
    • mapGet

      public static Expression mapGet(String fieldName, Expression key)
      Accesses a value from a map (object) field using the provided keyExpression.
      Parameters:
      fieldName - The field name of the map field.
      key - The key to access in the map.
      Returns:
      A new Expression representing the value associated with the given key in the map.
    • mapMerge

      public static Expression mapMerge(Expression firstMap, Expression secondMap)
    • mapMerge

      public static Expression mapMerge(String firstMapFieldName, Expression secondMap)
    • mapMerge

      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:
      firstMap - First map expression that will be merged.
      secondMap - Second map expression that will be merged.
      otherMaps - Additional maps to merge.
      Returns:
      A new Expression representing the mapMerge operation.
    • mapMerge

      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:
      firstMapFieldName - Field name of the first map expression that will be merged.
      secondMap - Second map expression that will be merged.
      otherMaps - Additional maps to merge.
      Returns:
      A new Expression representing the mapMerge operation.
    • mapRemove

      public static Expression mapRemove(Expression mapExpr, Expression key)
      Creates an expression that removes a key from a map.
      Parameters:
      mapExpr - The expression representing the map.
      key - The key to remove from the map.
      Returns:
      A new Expression representing the map with the key removed.
    • mapRemove

      public static Expression mapRemove(String mapField, Expression key)
      Creates an expression that removes a key from a map.
      Parameters:
      mapField - The field name of the map.
      key - The key to remove from the map.
      Returns:
      A new Expression representing the map with the key removed.
    • mapRemove

      public static Expression mapRemove(Expression mapExpr, String key)
      Creates an expression that removes a key from a map.
      Parameters:
      mapExpr - The expression representing the map.
      key - The key to remove from the map.
      Returns:
      A new Expression representing the map with the key removed.
    • mapRemove

      public static Expression mapRemove(String mapField, String key)
      Creates an expression that removes a key from a map.
      Parameters:
      mapField - The field name of the map.
      key - The key to remove from the map.
      Returns:
      A new Expression representing the map with the key removed.
    • mapSet

      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 null will retain the key with a null value. To remove a key entirely, use mapRemove.
      Parameters:
      mapExpr - The expression representing the map.
      key - The key to set. Must be an expression representing a string.
      value - The value to set.
      moreKeyValues - Additional key-value pairs to set.
      Returns:
      A new Expression representing the map with the entries set.
    • mapSet

      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 null will retain the key with a null value. To remove a key entirely, use mapRemove.
      Parameters:
      mapExpr - The map field to set entries in.
      key - The key to set.
      value - The value to set.
      moreKeyValues - Additional key-value pairs to set.
      Returns:
      A new Expression representing the map with the entries set.
    • mapSet

      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 null will retain the key with a null value. To remove a key entirely, use mapRemove.
      Parameters:
      mapField - The map field to set entries in.
      key - The key to set. Must be an expression representing a string.
      value - The value to set.
      moreKeyValues - Additional key-value pairs to set.
      Returns:
      A new Expression representing the map with the entries set.
    • mapSet

      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 null will retain the key with a null value. To remove a key entirely, use mapRemove.
      Parameters:
      mapField - The map field to set entries in.
      key - The key to set. Must be an expression representing a string.
      value - The value to set.
      moreKeyValues - Additional key-value pairs to set.
      Returns:
      A new Expression representing the map with the entries set.
    • mapKeys

      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.

      Parameters:
      mapExpr - The expression representing the map to get the keys of.
      Returns:
      A new Expression representing the keys of the map.
    • mapKeys

      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.

      Parameters:
      mapField - The map field to get the keys of.
      Returns:
      A new Expression representing the keys of the map.
    • mapValues

      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.

      Parameters:
      mapExpr - The expression representing the map to get the values of.
      Returns:
      A new Expression representing the values of the map.
    • mapValues

      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.

      Parameters:
      mapField - The map field to get the values of.
      Returns:
      A new Expression representing the values of the map.
    • mapEntries

      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.

      Parameters:
      mapExpr - The expression representing the map to get the entries of.
      Returns:
      A new Expression representing the entries of the map.
    • mapEntries

      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.

      Parameters:
      mapField - The map field to get the entries of.
      Returns:
      A new Expression representing the entries of the map.
    • reverse

      public static Expression reverse(Expression expr)
      Creates an expression that reverses a string, blob, or array.
      Parameters:
      expr - An expression evaluating to a string, blob, or array value, which will be reversed.
      Returns:
      A new Expression representing the reversed value.
    • reverse

      public static Expression reverse(String fieldName)
      Creates an expression that reverses the field value, which must be a string, blob, or array.
      Parameters:
      fieldName - A field evaluating to a string, blob, or array value.
      Returns:
      A new Expression representing the reversed value.
    • array

      public static Expression array(Object... elements)
      Creates an expression that creates a Firestore array value from an input object.
      Parameters:
      elements - The input elements to evaluate in the expression.
      Returns:
      A new Expression representing the array function.
    • array

      public static Expression array(List<Object> elements)
      Creates an expression that creates a Firestore array value from an input object.
      Parameters:
      elements - The input elements to evaluate in the expression.
      Returns:
      A new Expression representing the array function.
    • arrayConcat

      public static Expression arrayConcat(Expression firstArray, Object... otherArrays)
      Creates an expression that concatenates multiple arrays into a single array.
      Parameters:
      firstArray - The first array expression to concatenate.
      otherArrays - Additional arrays to concatenate.
      Returns:
      A new Expression representing the concatenated array.
    • arrayConcat

      public static Expression arrayConcat(String firstArrayField, Object... otherArrays)
      Creates an expression that concatenates multiple arrays into a single array.
      Parameters:
      firstArrayField - The field name of the first array to concatenate.
      otherArrays - Additional arrays to concatenate.
      Returns:
      A new Expression representing the concatenated array.
    • arrayReverse

      public static Expression arrayReverse(Expression array)
      Creates an expression that reverses an array.
      Parameters:
      array - The expression representing the array to reverse.
      Returns:
      A new Expression representing the reversed array.
    • arrayReverse

      public static Expression arrayReverse(String arrayFieldName)
      Creates an expression that reverses an array.
      Parameters:
      arrayFieldName - The field name of the array to reverse.
      Returns:
      A new Expression representing the reversed array.
    • arrayFilter

      public static Expression arrayFilter(Expression array, String alias, BooleanExpression filter)
      Filters an array expression based on a predicate.
      Parameters:
      array - The expression representing the array to filter.
      alias - The alias for the current element in the filter expression.
      filter - The predicate boolean expression used to filter the elements.
      Returns:
      A new Expression representing the filtered array.
    • arrayFilter

      public static Expression arrayFilter(String arrayFieldName, String alias, BooleanExpression filter)
      Filters an array field based on a predicate.
      Parameters:
      arrayFieldName - The field name of the array to filter.
      alias - The alias for the current element in the filter expression.
      filter - The predicate boolean expression used to filter the elements.
      Returns:
      A new Expression representing the filtered array.
    • arrayTransform

      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:
      array - The expression representing the array to transform.
      elementAlias - The alias for the current element in the transform expression.
      transform - The expression used to transform the elements.
      Returns:
      A new Expression representing the transformed array.
    • arrayTransform

      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:
      arrayFieldName - The field name of the array to transform.
      elementAlias - The alias for the current element in the transform expression.
      transform - The expression used to transform the elements.
      Returns:
      A new Expression representing the transformed array.
    • arrayTransformWithIndex

      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:
      array - The expression representing the array to transform.
      elementAlias - The alias for the current element in the transform expression.
      indexAlias - The alias for the current index.
      transform - The expression used to transform the elements.
      Returns:
      A new Expression representing the transformed array.
    • arrayTransformWithIndex

      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:
      arrayFieldName - The field name of the array to transform.
      elementAlias - The alias for the current element in the transform expression.
      indexAlias - The alias for the current index.
      transform - The expression used to transform the elements.
      Returns:
      A new Expression representing the transformed array.
    • arraySlice

      public static Expression arraySlice(Expression array, Expression offset, Expression length)
      Creates an expression that returns a slice of an array.
      Parameters:
      array - The expression representing the array to slice.
      offset - The starting index.
      length - The number of elements to return.
      Returns:
      A new Expression representing the array slice.
    • arraySlice

      public static Expression arraySlice(Expression array, int offset, int length)
      Creates an expression that returns a slice of an array.
      Parameters:
      array - The expression representing the array to slice.
      offset - The starting index.
      length - The number of elements to return.
      Returns:
      A new Expression representing the array slice.
    • arraySlice

      public static Expression arraySlice(String arrayFieldName, int offset, int length)
      Creates an expression that returns a slice of an array.
      Parameters:
      arrayFieldName - The field name of the array to slice.
      offset - The starting index.
      length - The number of elements to return.
      Returns:
      A new Expression representing the array slice.
    • arraySlice

      public static Expression arraySlice(String arrayFieldName, Expression offset, Expression length)
      Creates an expression that returns a slice of an array.
      Parameters:
      arrayFieldName - The field name of the array to slice.
      offset - The starting index.
      length - The number of elements to return.
      Returns:
      A new Expression representing the array slice.
    • arraySliceToEnd

      public static Expression arraySliceToEnd(Expression array, Expression offset)
      Creates an expression that returns a slice of an array to its end.
      Parameters:
      array - The expression representing the array to slice.
      offset - The expression representing the starting index.
      Returns:
      A new Expression representing the array slice.
    • arraySliceToEnd

      public static Expression arraySliceToEnd(Expression array, int offset)
      Creates an expression that returns a slice of an array to its end.
      Parameters:
      array - The expression representing the array to slice.
      offset - The starting index.
      Returns:
      A new Expression representing the array slice.
    • arraySliceToEnd

      public static Expression arraySliceToEnd(String arrayFieldName, int offset)
      Creates an expression that returns a slice of an array to its end.
      Parameters:
      arrayFieldName - The field name of the array to slice.
      offset - The starting index.
      Returns:
      A new Expression representing the array slice.
    • arraySliceToEnd

      public static Expression arraySliceToEnd(String arrayFieldName, Expression offset)
      Creates an expression that returns a slice of an array to its end.
      Parameters:
      arrayFieldName - The field name of the array to slice.
      offset - The expression representing the starting index.
      Returns:
      A new Expression representing the array slice.
    • arrayContains

      public static BooleanExpression arrayContains(Expression array, Expression element)
      Creates an expression that checks if an array contains a specified element.
      Parameters:
      array - The expression representing the array.
      element - The element to check for.
      Returns:
      A new BooleanExpression representing the array contains comparison.
    • arrayContains

      public static BooleanExpression arrayContains(String arrayFieldName, Expression element)
      Creates an expression that checks if an array contains a specified element.
      Parameters:
      arrayFieldName - The field name of the array.
      element - The element to check for.
      Returns:
      A new BooleanExpression representing the array contains comparison.
    • arrayContains

      public static BooleanExpression arrayContains(Expression array, Object element)
      Creates an expression that checks if an array contains a specified element.
      Parameters:
      array - The expression representing the array.
      element - The element to check for.
      Returns:
      A new BooleanExpression representing the array contains comparison.
    • arrayContains

      public static BooleanExpression arrayContains(String arrayFieldName, Object element)
      Creates an expression that checks if an array contains a specified element.
      Parameters:
      arrayFieldName - The field name of the array.
      element - The element to check for.
      Returns:
      A new BooleanExpression representing the array contains comparison.
    • arrayContainsAll

      public static BooleanExpression arrayContainsAll(Expression array, List<Object> values)
      Creates an expression that checks if an array contains all of the provided values.
      Parameters:
      array - The expression representing the array.
      values - The values to check for.
      Returns:
      A new BooleanExpression representing the array contains all comparison.
    • arrayContainsAll

      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:
      array - The expression representing the array.
      arrayExpression - The expression representing the array of values to check for.
      Returns:
      A new BooleanExpression representing the array contains all comparison.
    • arrayContainsAll

      public static BooleanExpression arrayContainsAll(String arrayFieldName, List<Object> values)
      Creates an expression that checks if an array contains all of the provided values.
      Parameters:
      arrayFieldName - The field name of the array.
      values - The values to check for.
      Returns:
      A new BooleanExpression representing the array contains all comparison.
    • arrayContainsAll

      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:
      arrayFieldName - The field name of the array.
      arrayExpression - The expression representing the array of values to check for.
      Returns:
      A new BooleanExpression representing the array contains all comparison.
    • arrayContainsAny

      public static BooleanExpression arrayContainsAny(Expression array, List<Object> values)
      Creates an expression that checks if an array contains any of the provided values.
      Parameters:
      array - The expression representing the array.
      values - The values to check for.
      Returns:
      A new BooleanExpression representing the array contains any comparison.
    • arrayContainsAny

      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:
      array - The expression representing the array.
      arrayExpression - The expression representing the array of values to check for.
      Returns:
      A new BooleanExpression representing the array contains any comparison.
    • arrayContainsAny

      public static BooleanExpression arrayContainsAny(String arrayFieldName, List<Object> values)
      Creates an expression that checks if an array contains any of the provided values.
      Parameters:
      arrayFieldName - The field name of the array.
      values - The values to check for.
      Returns:
      A new BooleanExpression representing the array contains any comparison.
    • arrayContainsAny

      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:
      arrayFieldName - The field name of the array.
      arrayExpression - The expression representing the array of values to check for.
      Returns:
      A new BooleanExpression representing the array contains any comparison.
    • arrayLength

      public static Expression arrayLength(Expression array)
      Creates an expression that returns the length of an array.
      Parameters:
      array - The expression representing the array.
      Returns:
      A new Expression representing the length of the array.
    • arrayLength

      public static Expression arrayLength(String arrayFieldName)
      Creates an expression that returns the length of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      Returns:
      A new Expression representing the length of the array.
    • arrayFirst

      public static Expression arrayFirst(Expression array)
      Creates an expression that returns the first element of an array.
      Parameters:
      array - The expression representing the array.
      Returns:
      A new Expression representing the first element of the array.
    • arrayFirst

      public static Expression arrayFirst(String arrayFieldName)
      Creates an expression that returns the first element of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      Returns:
      A new Expression representing the first element of the array.
    • arrayFirstN

      public static Expression arrayFirstN(Expression array, Expression n)
      Creates an expression that returns the first n elements of an array.
      Parameters:
      array - The expression representing the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the first n elements of the array.
    • arrayFirstN

      public static Expression arrayFirstN(Expression array, int n)
      Creates an expression that returns the first n elements of an array.
      Parameters:
      array - The expression representing the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the first n elements of the array.
    • arrayFirstN

      public static Expression arrayFirstN(String arrayFieldName, int n)
      Creates an expression that returns the first n elements of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the first n elements of the array.
    • arrayFirstN

      public static Expression arrayFirstN(String arrayFieldName, Expression n)
      Creates an expression that returns the first n elements of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the first n elements of the array.
    • arrayLast

      public static Expression arrayLast(Expression array)
      Creates an expression that returns the last element of an array.
      Parameters:
      array - The expression representing the array.
      Returns:
      A new Expression representing the last element of the array.
    • arrayLast

      public static Expression arrayLast(String arrayFieldName)
      Creates an expression that returns the last element of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      Returns:
      A new Expression representing the last element of the array.
    • arrayLastN

      public static Expression arrayLastN(Expression array, Expression n)
      Creates an expression that returns the last n elements of an array.
      Parameters:
      array - The expression representing the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the last n elements of the array.
    • arrayLastN

      public static Expression arrayLastN(Expression array, int n)
      Creates an expression that returns the last n elements of an array.
      Parameters:
      array - The expression representing the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the last n elements of the array.
    • arrayLastN

      public static Expression arrayLastN(String arrayFieldName, int n)
      Creates an expression that returns the last n elements of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the last n elements of the array.
    • arrayLastN

      public static Expression arrayLastN(String arrayFieldName, Expression n)
      Creates an expression that returns the last n elements of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the last n elements of the array.
    • arrayMinimum

      public static Expression arrayMinimum(Expression array)
      Creates an expression that returns the minimum value of an array.
      Parameters:
      array - The expression representing the array.
      Returns:
      A new Expression representing the minimum value of the array.
    • arrayMinimum

      public static Expression arrayMinimum(String arrayFieldName)
      Creates an expression that returns the minimum value of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      Returns:
      A new Expression representing the minimum value of the array.
    • arrayMinimumN

      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:
      array - The expression representing the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the n minimum values of the array.
    • arrayMinimumN

      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:
      array - The expression representing the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the n minimum values of the array.
    • arrayMinimumN

      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:
      arrayFieldName - The field name of the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the n minimum values of the array.
    • arrayMinimumN

      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:
      arrayFieldName - The field name of the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the n minimum values of the array.
    • arrayMaximum

      public static Expression arrayMaximum(Expression array)
      Creates an expression that returns the maximum value of an array.
      Parameters:
      array - The expression representing the array.
      Returns:
      A new Expression representing the maximum value of the array.
    • arrayMaximum

      public static Expression arrayMaximum(String arrayFieldName)
      Creates an expression that returns the maximum value of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      Returns:
      A new Expression representing the maximum value of the array.
    • arrayMaximumN

      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:
      array - The expression representing the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the n maximum values of the array.
    • arrayMaximumN

      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:
      array - The expression representing the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the n maximum values of the array.
    • arrayMaximumN

      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:
      arrayFieldName - The field name of the array.
      n - The number of elements to return.
      Returns:
      A new Expression representing the n maximum values of the array.
    • arrayMaximumN

      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:
      arrayFieldName - The field name of the array.
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the n maximum values of the array.
    • arrayIndexOf

      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:
      array - The expression representing the array.
      value - The value to search for.
      Returns:
      A new Expression representing the index.
    • arrayIndexOf

      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:
      array - The expression representing the array.
      value - The value to search for.
      Returns:
      A new Expression representing the index.
    • arrayIndexOf

      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:
      arrayFieldName - The field name of the array.
      value - The value to search for.
      Returns:
      A new Expression representing the index.
    • arrayIndexOf

      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:
      arrayFieldName - The field name of the array.
      value - The value to search for.
      Returns:
      A new Expression representing the index.
    • arrayLastIndexOf

      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:
      array - The expression representing the array.
      value - The value to search for.
      Returns:
      A new Expression representing the last index.
    • arrayLastIndexOf

      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:
      array - The expression representing the array.
      value - The value to search for.
      Returns:
      A new Expression representing the last index.
    • arrayLastIndexOf

      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:
      arrayFieldName - The field name of the array.
      value - The value to search for.
      Returns:
      A new Expression representing the last index.
    • arrayLastIndexOf

      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:
      arrayFieldName - The field name of the array.
      value - The value to search for.
      Returns:
      A new Expression representing the last index.
    • arrayIndexOfAll

      public static Expression arrayIndexOfAll(Expression array, Expression value)
      Creates an expression that returns all indices of a value in an array.
      Parameters:
      array - The expression representing the array.
      value - The value to search for.
      Returns:
      A new Expression representing the indices.
    • arrayIndexOfAll

      public static Expression arrayIndexOfAll(Expression array, Object value)
      Creates an expression that returns all indices of a value in an array.
      Parameters:
      array - The expression representing the array.
      value - The value to search for.
      Returns:
      A new Expression representing the indices.
    • arrayIndexOfAll

      public static Expression arrayIndexOfAll(String arrayFieldName, Object value)
      Creates an expression that returns all indices of a value in an array.
      Parameters:
      arrayFieldName - The field name of the array.
      value - The value to search for.
      Returns:
      A new Expression representing the indices.
    • arrayIndexOfAll

      public static Expression arrayIndexOfAll(String arrayFieldName, Expression value)
      Creates an expression that returns all indices of a value in an array.
      Parameters:
      arrayFieldName - The field name of the array.
      value - The value to search for.
      Returns:
      A new Expression representing the indices.
    • arrayGet

      public static Expression arrayGet(Expression array, Expression offset)
      Creates an expression that returns an element from an array at a specified index.
      Parameters:
      array - The expression representing the array.
      offset - The index of the element to return.
      Returns:
      A new Expression representing the element at the specified index.
    • arrayGet

      public static Expression arrayGet(Expression array, int offset)
      Creates an expression that returns an element from an array at a specified index.
      Parameters:
      array - The expression representing the array.
      offset - The index of the element to return.
      Returns:
      A new Expression representing the element at the specified index.
    • arrayGet

      public static Expression arrayGet(String arrayFieldName, Expression offset)
      Creates an expression that returns an element from an array at a specified index.
      Parameters:
      arrayFieldName - The field name of the array.
      offset - The index of the element to return.
      Returns:
      A new Expression representing the element at the specified index.
    • arrayGet

      public static Expression arrayGet(String arrayFieldName, int offset)
      Creates an expression that returns an element from an array at a specified index.
      Parameters:
      arrayFieldName - The field name of the array.
      offset - The index of the element to return.
      Returns:
      A new Expression representing the element at the specified index.
    • arraySum

      public static Expression arraySum(Expression array)
      Creates an expression that returns the sum of the elements of an array.
      Parameters:
      array - The expression representing the array.
      Returns:
      A new Expression representing the sum of the elements of the array.
    • arraySum

      public static Expression arraySum(String arrayFieldName)
      Creates an expression that returns the sum of the elements of an array.
      Parameters:
      arrayFieldName - The field name of the array.
      Returns:
      A new Expression representing the sum of the elements of the array.
    • cosineDistance

      public static Expression cosineDistance(Expression vector1, Expression vector2)
      Creates an expression that calculates the cosine distance between two vectors.
      Parameters:
      vector1 - The first vector.
      vector2 - The second vector.
      Returns:
      A new Expression representing the cosine distance.
    • cosineDistance

      public static Expression cosineDistance(Expression vector1, double[] vector2)
      Creates an expression that calculates the cosine distance between two vectors.
      Parameters:
      vector1 - The first vector.
      vector2 - The second vector.
      Returns:
      A new Expression representing the cosine distance.
    • cosineDistance

      public static Expression cosineDistance(String vectorFieldName, Expression vector)
      Creates an expression that calculates the cosine distance between two vectors.
      Parameters:
      vectorFieldName - The field name of the first vector.
      vector - The second vector.
      Returns:
      A new Expression representing the cosine distance.
    • cosineDistance

      public static Expression cosineDistance(String vectorFieldName, double[] vector)
      Creates an expression that calculates the cosine distance between two vectors.
      Parameters:
      vectorFieldName - The field name of the first vector.
      vector - The second vector.
      Returns:
      A new Expression representing the cosine distance.
    • dotProduct

      public static Expression dotProduct(Expression vector1, Expression vector2)
      Creates an expression that calculates the dot product of two vectors.
      Parameters:
      vector1 - The first vector.
      vector2 - The second vector.
      Returns:
      A new Expression representing the dot product.
    • dotProduct

      public static Expression dotProduct(Expression vector1, double[] vector2)
      Creates an expression that calculates the dot product of two vectors.
      Parameters:
      vector1 - The first vector.
      vector2 - The second vector.
      Returns:
      A new Expression representing the dot product.
    • dotProduct

      public static Expression dotProduct(String vectorFieldName, Expression vector)
      Creates an expression that calculates the dot product of two vectors.
      Parameters:
      vectorFieldName - The field name of the first vector.
      vector - The second vector.
      Returns:
      A new Expression representing the dot product.
    • dotProduct

      public static Expression dotProduct(String vectorFieldName, double[] vector)
      Creates an expression that calculates the dot product of two vectors.
      Parameters:
      vectorFieldName - The field name of the first vector.
      vector - The second vector.
      Returns:
      A new Expression representing the dot product.
    • euclideanDistance

      public static Expression euclideanDistance(Expression vector1, Expression vector2)
      Creates an expression that calculates the Euclidean distance between two vectors.
      Parameters:
      vector1 - The first vector.
      vector2 - The second vector.
      Returns:
      A new Expression representing the Euclidean distance.
    • euclideanDistance

      public static Expression euclideanDistance(Expression vector1, double[] vector2)
      Creates an expression that calculates the Euclidean distance between two vectors.
      Parameters:
      vector1 - The first vector.
      vector2 - The second vector.
      Returns:
      A new Expression representing the Euclidean distance.
    • euclideanDistance

      public static Expression euclideanDistance(String vectorFieldName, Expression vector)
      Creates an expression that calculates the Euclidean distance between two vectors.
      Parameters:
      vectorFieldName - The field name of the first vector.
      vector - The second vector.
      Returns:
      A new Expression representing the Euclidean distance.
    • euclideanDistance

      public static Expression euclideanDistance(String vectorFieldName, double[] vector)
      Creates an expression that calculates the Euclidean distance between two vectors.
      Parameters:
      vectorFieldName - The field name of the first vector.
      vector - The second vector.
      Returns:
      A new Expression representing the Euclidean distance.
    • vectorLength

      public static Expression vectorLength(Expression vectorExpression)
      Creates an expression that calculates the length of a vector.
      Parameters:
      vectorExpression - The expression representing the vector.
      Returns:
      A new Expression representing the length of the vector.
    • vectorLength

      public static Expression vectorLength(String fieldName)
      Creates an expression that calculates the length of a vector.
      Parameters:
      fieldName - The field name of the vector.
      Returns:
      A new Expression representing the length of the vector.
    • unixMicrosToTimestamp

      public static Expression unixMicrosToTimestamp(Expression expr)
      Creates an expression that converts a Unix timestamp in microseconds to a Firestore timestamp.
      Parameters:
      expr - The expression representing the Unix timestamp in microseconds.
      Returns:
      A new Expression representing the Firestore timestamp.
    • unixMicrosToTimestamp

      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.
      Parameters:
      fieldName - The name of the field containing the number of microseconds since epoch.
      Returns:
      A new Expression representing the timestamp.
    • timestampToUnixMicros

      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).
      Parameters:
      expr - The expression representing the timestamp.
      Returns:
      A new Expression representing the number of microseconds since epoch.
    • timestampToUnixMicros

      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).
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      Returns:
      A new Expression representing the number of microseconds since epoch.
    • unixMillisToTimestamp

      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.
      Parameters:
      expr - The expression representing the number of milliseconds since epoch.
      Returns:
      A new Expression representing the timestamp.
    • unixMillisToTimestamp

      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.
      Parameters:
      fieldName - The name of the field containing the number of milliseconds since epoch.
      Returns:
      A new Expression representing the timestamp.
    • timestampToUnixMillis

      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).
      Parameters:
      expr - The expression representing the timestamp.
      Returns:
      A new Expression representing the number of milliseconds since epoch.
    • timestampToUnixMillis

      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).
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      Returns:
      A new Expression representing the number of milliseconds since epoch.
    • unixSecondsToTimestamp

      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.
      Parameters:
      expr - The expression representing the number of seconds since epoch.
      Returns:
      A new Expression representing the timestamp.
    • unixSecondsToTimestamp

      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.
      Parameters:
      fieldName - The name of the field containing the number of seconds since epoch.
      Returns:
      A new Expression representing the timestamp.
    • timestampToUnixSeconds

      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).
      Parameters:
      expr - The expression representing the timestamp.
      Returns:
      A new Expression representing the number of seconds since epoch.
    • timestampToUnixSeconds

      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).
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      Returns:
      A new Expression representing the number of seconds since epoch.
    • timestampAdd

      public static Expression timestampAdd(Expression timestamp, Expression unit, Expression amount)
      Creates an expression that adds a specified amount of time to a timestamp.
      Parameters:
      timestamp - The expression representing the timestamp.
      unit - The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The expression representing the amount of time to add.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampAdd

      public static Expression timestampAdd(Expression timestamp, String unit, long amount)
      Creates an expression that adds a specified amount of time to a timestamp.
      Parameters:
      timestamp - The expression representing the timestamp.
      unit - The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to add.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampAdd

      public static Expression timestampAdd(String fieldName, Expression unit, Expression amount)
      Creates an expression that adds a specified amount of time to a timestamp.
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      unit - The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The expression representing the amount of time to add.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampAdd

      public static Expression timestampAdd(String fieldName, String unit, long amount)
      Creates an expression that adds a specified amount of time to a timestamp.
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      unit - The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to add.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampSubtract

      public static Expression timestampSubtract(Expression timestamp, Expression unit, Expression amount)
      Creates an expression that subtracts a specified amount of time to a timestamp.
      Parameters:
      timestamp - The expression representing the timestamp.
      unit - The expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The expression representing the amount of time to subtract.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampSubtract

      public static Expression timestampSubtract(Expression timestamp, String unit, long amount)
      Creates an expression that subtracts a specified amount of time to a timestamp.
      Parameters:
      timestamp - The expression representing the timestamp.
      unit - The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to subtract.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampSubtract

      public static Expression timestampSubtract(String fieldName, Expression unit, Expression amount)
      Creates an expression that subtracts a specified amount of time to a timestamp.
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      unit - The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to subtract.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampSubtract

      public static Expression timestampSubtract(String fieldName, String unit, long amount)
      Creates an expression that subtracts a specified amount of time to a timestamp.
      Parameters:
      fieldName - The name of the field that contains the timestamp.
      unit - The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to subtract.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampTruncate

      public static Expression timestampTruncate(Expression timestamp, String granularity)
      Creates an expression that truncates a timestamp to a specified granularity.
      Parameters:
      timestamp - The timestamp expression.
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncate

      public static Expression timestampTruncate(Expression timestamp, Expression granularity)
      Creates an expression that truncates a timestamp to a specified granularity.
      Parameters:
      timestamp - The timestamp expression.
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncate

      public static Expression timestampTruncate(String fieldName, String granularity)
      Creates an expression that truncates a timestamp to a specified granularity.
      Parameters:
      fieldName - The name of the field containing the timestamp.
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncate

      public static Expression timestampTruncate(String fieldName, Expression granularity)
      Creates an expression that truncates a timestamp to a specified granularity.
      Parameters:
      fieldName - The name of the field containing the timestamp.
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      timestamp - The timestamp expression.
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      timestamp - The timestamp expression.
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      timestamp - The timestamp expression.
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The 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:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      timestamp - The timestamp expression.
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The 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:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The 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:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The 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:
      A new Expression representing the truncated timestamp.
    • timestampDiff

      public static Expression timestampDiff(Expression end, Expression start, Expression unit)
      Creates an expression that calculates the difference between two timestamps.
      Parameters:
      end - The ending timestamp expression.
      start - The starting timestamp expression.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampDiff

      public static Expression timestampDiff(Expression end, Expression start, String unit)
      Creates an expression that calculates the difference between two timestamps.
      Parameters:
      end - The ending timestamp expression.
      start - The starting timestamp expression.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampDiff

      public static Expression timestampDiff(String endFieldName, String startFieldName, String unit)
      Creates an expression that calculates the difference between two timestamps.
      Parameters:
      endFieldName - The ending timestamp field name.
      startFieldName - The starting timestamp field name.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampDiff

      public static Expression timestampDiff(String endFieldName, Expression start, String unit)
      Creates an expression that calculates the difference between two timestamps.
      Parameters:
      endFieldName - The ending timestamp field name.
      start - The starting timestamp expression.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampDiff

      public static Expression timestampDiff(Expression end, String startFieldName, String unit)
      Creates an expression that calculates the difference between two timestamps.
      Parameters:
      end - The ending timestamp expression.
      startFieldName - The starting timestamp field name.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampExtract

      public static Expression timestampExtract(Expression timestamp, Expression part)
      Creates an expression that extracts a specified part from a timestamp.
      Parameters:
      timestamp - The timestamp expression.
      part - The 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:
      A new Expression representing the extracted part.
    • timestampExtract

      public static Expression timestampExtract(Expression timestamp, String part)
      Creates an expression that extracts a specified part from a timestamp.
      Parameters:
      timestamp - The timestamp expression.
      part - The 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:
      A new Expression representing the extracted part.
    • timestampExtract

      public static Expression timestampExtract(String fieldName, Expression part)
      Creates an expression that extracts a specified part from a timestamp.
      Parameters:
      fieldName - The name of the field containing the timestamp.
      part - The 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:
      A new Expression representing the extracted part.
    • timestampExtract

      public static Expression timestampExtract(String fieldName, String part)
      Creates an expression that extracts a specified part from a timestamp.
      Parameters:
      fieldName - The name of the field containing the timestamp.
      part - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      timestamp - The timestamp expression.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      timestamp - The timestamp expression.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      timestamp - The timestamp expression.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      timestamp - The timestamp expression.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      fieldName - The name of the field containing the timestamp.
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • conditional

      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:
      condition - The condition to evaluate.
      thenExpr - The expression to evaluate if the condition is true.
      elseExpr - The expression to evaluate if the condition is false.
      Returns:
      A new Expression representing the conditional operation.
    • conditional

      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:
      condition - The condition to evaluate.
      thenValue - Value if the condition is true.
      elseValue - Value if the condition is false.
      Returns:
      A new Expression representing the conditional operation.
    • ifError

      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:
      tryExpr - The try expression.
      catchExpr - The catch expression that will be evaluated and returned if the tryExpr produces an error.
      Returns:
      A new Expression representing the ifError operation.
    • ifError

      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:
      tryExpr - The try boolean expression.
      catchExpr - The catch boolean expression that will be evaluated and returned if the tryExpr produces an error.
      Returns:
      A new BooleanExpression representing the ifError operation.
    • ifError

      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:
      tryExpr - The try expression.
      catchValue - The value that will be returned if the tryExpr produces an error.
      Returns:
      A new Expression representing the ifError operation.
    • isError

      public static BooleanExpression isError(Expression expr)
      Creates an expression that checks if a given expression produces an error.
      Parameters:
      expr - The expression to check.
      Returns:
      A new BooleanExpression representing the `isError` check.
    • geoDistance

      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:
      fieldName - Specifies the field in the document which contains the first GeoPoint for distance computation.
      location - Compute distance to this GeoPoint.
      Returns:
      A new Expression representing the geoDistance operation.
    • geoDistance

      @BetaApi 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:
      field - Specifies the field in the document which contains the first GeoPoint for distance computation.
      location - Compute distance to this GeoPoint.
      Returns:
      A new Expression representing the geoDistance operation.
    • documentMatches

      @BetaApi 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")))
       
      Parameters:
      rquery - Define the search query using the search domain-specific language (DSL).
      Returns:
      A new BooleanExpression representing the documentMatches operation.
    • score

      @BetaApi 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:
      A new Expression representing the score operation.
    • between

      @InternalApi public final BooleanExpression between(Expression lowerBound, Expression upperBound)
    • between

      @InternalApi public final BooleanExpression between(Object lowerBound, Object upperBound)
    • documentId

      public static Expression documentId(Expression documentPath)
      Creates an expression that returns the document ID from a path.
      Parameters:
      documentPath - An expression the evaluates to document path.
      Returns:
      A new Expression representing the documentId operation.
    • documentId

      public static Expression documentId(String documentPath)
      Creates an expression that returns the document ID from a path.
      Parameters:
      documentPath - The string representation of the document path.
      Returns:
      A new Expression representing the documentId operation.
    • documentId

      public static Expression documentId(DocumentReference docRef)
      Creates an expression that returns the document ID from a DocumentReference.
      Parameters:
      docRef - The DocumentReference.
      Returns:
      A new Expression representing the documentId operation.
    • collectionId

      public static Expression collectionId(Expression path)
      Creates an expression that returns the collection ID from a path.
      Parameters:
      path - An expression the evaluates to document path.
      Returns:
      A new Expression representing the collectionId operation.
    • collectionId

      public static Expression collectionId(String pathFieldName)
      Creates an expression that returns the collection ID from a path.
      Parameters:
      pathFieldName - The field name of the path.
      Returns:
      A new Expression representing the collectionId operation.
    • parent

      public static Expression parent(Expression documentPath)
      Creates an expression that returns the parent document of a document reference.
      Parameters:
      documentPath - An expression that evaluates to a document path.
      Returns:
      A new Expression representing the parent operation.
    • parent

      public static Expression parent(String documentPath)
      Creates an expression that returns the parent document of a document reference.
      Parameters:
      documentPath - The string representation of the document path.
      Returns:
      A new Expression representing the parent operation.
    • parent

      public static Expression parent(DocumentReference docRef)
      Creates an expression that returns the parent document of a document reference.
      Parameters:
      docRef - The DocumentReference.
      Returns:
      A new Expression representing the parent operation.
    • exists

      public static BooleanExpression exists(Expression value)
      Creates an expression that checks if a field exists.
      Parameters:
      value - An expression evaluates to the name of the field to check.
      Returns:
      A new Expression representing the exists check.
    • exists

      public static BooleanExpression exists(String fieldName)
      Creates an expression that checks if a field exists.
      Parameters:
      fieldName - The field name to check.
      Returns:
      A new Expression representing the exists check.
    • isAbsent

      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.
      Parameters:
      value - The expression to check.
      Returns:
      A new BooleanExpression representing the isAbsent operation.
    • isAbsent

      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.
      Parameters:
      fieldName - The field to check.
      Returns:
      A new BooleanExpression representing the isAbsent operation.
    • type

      public static Expression type(Expression expr)
      Creates an expression that returns a string indicating the type of the value this expression evaluates to.
      Parameters:
      expr - The expression to get the type of.
      Returns:
      A new Expression representing the type operation.
    • type

      public static Expression type(String fieldName)
      Creates an expression that returns a string indicating the type of the value this field evaluates to.
      Parameters:
      fieldName - The name of the field to get the type of.
      Returns:
      A new Expression representing the type operation.
    • isType

      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:
      expr - The expression to check the type of.
      type - The type to check for.
      Returns:
      A new BooleanExpression that evaluates to true if the expression's result is of the given type, false otherwise.
    • isType

      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:
      fieldName - The name of the field to check the type of.
      type - The type to check for.
      Returns:
      A new BooleanExpression that evaluates to true if the expression's result is of the given type, false otherwise.
    • round

      public static Expression round(Expression numericExpr)
      Creates an expression that rounds numericExpr to nearest integer.

      Rounds away from zero in halfway cases.

      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing an integer result from the round operation.
    • round

      public static Expression round(String numericField)
      Creates an expression that rounds numericField to nearest integer.

      Rounds away from zero in halfway cases.

      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing an integer result from the round operation.
    • roundToPrecision

      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:
      numericExpr - An expression that returns number when evaluated.
      decimalPlace - The number of decimal places to round.
      Returns:
      A new Expression representing the round operation.
    • roundToPrecision

      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:
      numericField - Name of field that returns number when evaluated.
      decimalPlace - The number of decimal places to round.
      Returns:
      A new Expression representing the round operation.
    • roundToPrecision

      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:
      numericExpr - An expression that returns number when evaluated.
      decimalPlace - The number of decimal places to round.
      Returns:
      A new Expression representing the round operation.
    • roundToPrecision

      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:
      numericField - Name of field that returns number when evaluated.
      decimalPlace - The number of decimal places to round.
      Returns:
      A new Expression representing the round operation.
    • 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:
      A new Expression representing a random double result from the rand operation.
    • trunc

      public static Expression trunc(Expression numericExpr)
      Creates an expression that truncates numericExpr to an integer.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing the trunc operation.
    • trunc

      public static Expression trunc(String numericField)
      Creates an expression that truncates numericField to an integer.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing the trunc operation.
    • truncToPrecision

      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:
      numericExpr - An expression that returns number when evaluated.
      decimalPlace - The number of decimal places to truncate.
      Returns:
      A new Expression representing the trunc operation.
    • truncToPrecision

      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:
      numericField - Name of field that returns number when evaluated.
      decimalPlace - The number of decimal places to truncate.
      Returns:
      A new Expression representing the trunc operation.
    • truncToPrecision

      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:
      numericExpr - An expression that returns number when evaluated.
      decimalPlace - The number of decimal places to truncate.
      Returns:
      A new Expression representing the trunc operation.
    • truncToPrecision

      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:
      numericField - Name of field that returns number when evaluated.
      decimalPlace - The number of decimal places to truncate.
      Returns:
      A new Expression representing the trunc operation.
    • ceil

      public static Expression ceil(Expression numericExpr)
      Creates an expression that returns the smallest integer that isn't less than numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing an integer result from the ceil operation.
    • ceil

      public static Expression ceil(String numericField)
      Creates an expression that returns the smallest integer that isn't less than numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing an integer result from the ceil operation.
    • floor

      public static Expression floor(Expression numericExpr)
      Creates an expression that returns the largest integer that isn't less than numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing an integer result from the floor operation.
    • floor

      public static Expression floor(String numericField)
      Creates an expression that returns the largest integer that isn't less than numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing an integer result from the floor operation.
    • pow

      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:
      numericExpr - An expression that returns number when evaluated.
      exponent - The numeric power to raise the numericExpr.
      Returns:
      A new Expression representing a numeric result from raising numericExpr to the power of exponent.
    • pow

      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:
      numericField - Name of field that returns number when evaluated.
      exponent - The numeric power to raise the numericField.
      Returns:
      A new Expression representing a numeric result from raising numericField to the power of exponent.
    • pow

      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:
      numericExpr - An expression that returns number when evaluated.
      exponent - The numeric power to raise the numericExpr.
      Returns:
      A new Expression representing a numeric result from raising numericExpr to the power of exponent.
    • pow

      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:
      numericField - Name of field that returns number when evaluated.
      exponent - The numeric power to raise the numericField.
      Returns:
      A new Expression representing a numeric result from raising numericField to the power of exponent.
    • abs

      public static Expression abs(Expression numericExpr)
      Creates an expression that returns the absolute value of numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the absolute value operation.
    • abs

      public static Expression abs(String numericField)
      Creates an expression that returns the absolute value of numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the absolute value operation.
    • exp

      public static Expression exp(Expression numericExpr)
      Creates an expression that returns Euler's number e raised to the power of numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the exponentiation.
    • exp

      public static Expression exp(String numericField)
      Creates an expression that returns Euler's number e raised to the power of numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the exponentiation.
    • ln

      public static Expression ln(Expression numericExpr)
      Creates an expression that returns the natural logarithm (base e) of numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the natural logarithm.
    • ln

      public static Expression ln(String numericField)
      Creates an expression that returns the natural logarithm (base e) of numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the natural logarithm.
    • log

      public static Expression log(Expression numericExpr, Number base)
      Creates an expression that returns the logarithm of numericExpr with a given base.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      base - The base of the logarithm.
      Returns:
      A new Expression representing a numeric result from the logarithm of numericExpr with a given base.
    • log

      public static Expression log(String numericField, Number base)
      Creates an expression that returns the logarithm of numericField with a given base.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      base - The base of the logarithm.
      Returns:
      A new Expression representing a numeric result from the logarithm of numericField with a given base.
    • log

      public static Expression log(Expression numericExpr, Expression base)
      Creates an expression that returns the logarithm of numericExpr with a given base.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      base - The base of the logarithm.
      Returns:
      A new Expression representing a numeric result from the logarithm of numericExpr with a given base.
    • log

      public static Expression log(String numericField, Expression base)
      Creates an expression that returns the logarithm of numericField with a given base.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      base - The base of the logarithm.
      Returns:
      A new Expression representing a numeric result from the logarithm of numericField with a given base.
    • log10

      public static Expression log10(Expression numericExpr)
      Creates an expression that returns the base 10 logarithm of numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the base 10 logarithm.
    • log10

      public static Expression log10(String numericField)
      Creates an expression that returns the base 10 logarithm of numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the base 10 logarithm.
    • sqrt

      public static Expression sqrt(Expression numericExpr)
      Creates an expression that returns the square root of numericExpr.
      Parameters:
      numericExpr - An expression that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the square root operation.
    • sqrt

      public static Expression sqrt(String numericField)
      Creates an expression that returns the square root of numericField.
      Parameters:
      numericField - Name of field that returns number when evaluated.
      Returns:
      A new Expression representing the numeric result of the square root operation.
    • isNotNaN

      public static BooleanExpression isNotNaN(Expression expr)
      Creates an expression that checks if the results of expr is NOT 'NaN' (Not a Number).
      Parameters:
      expr - The expression to check.
      Returns:
      A new BooleanExpression representing the isNotNan operation.
    • isNotNaN

      public static BooleanExpression isNotNaN(String fieldName)
      Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).
      Parameters:
      fieldName - The field to check.
      Returns:
      A new BooleanExpression representing the isNotNan operation.
    • logicalMaximum

      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:
      expr - The first operand expression.
      others - Optional additional expressions or literals.
      Returns:
      A new Expression representing the logical maximum operation.
    • logicalMaximum

      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:
      fieldName - The first operand field name.
      others - Optional additional expressions or literals.
      Returns:
      A new Expression representing the logical maximum operation.
    • logicalMinimum

      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:
      expr - The first operand expression.
      others - Optional additional expressions or literals.
      Returns:
      A new Expression representing the logical minimum operation.
    • logicalMinimum

      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:
      fieldName - The first operand field name.
      others - Optional additional expressions or literals.
      Returns:
      A new Expression representing the logical minimum operation.
    • concat

      public Expression concat(Object... others)
      Creates an expression that concatenates this expression with other values.
      Parameters:
      others - Optional additional expressions or constants to concatenate.
      Returns:
      A new Expression representing the concatenated value.
    • ifAbsent

      public Expression ifAbsent(Object elseValue)
      Creates an expression that returns a default value if this expression evaluates to an absent value.
      Parameters:
      elseValue - The default value.
      Returns:
      A new Expression representing the ifAbsent operation.
    • ifNull

      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(com.google.cloud.firestore.pipeline.expressions.Expression,com.google.cloud.firestore.pipeline.expressions.Expression) only triggers for missing fields.

      Parameters:
      elseValue - The default value that will be returned.
      Returns:
      A new Expression representing the ifNull operation.
    • coalesce

      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:
      second - The next expression or literal to evaluate.
      others - Additional expressions or literals to evaluate.
      Returns:
      A new Expression representing the coalesce operation.
    • join

      public Expression join(String delimiter)
      Creates an expression that joins the elements of this array expression into a string.
      Parameters:
      delimiter - The delimiter to use.
      Returns:
      A new Expression representing the join operation.
    • join

      public Expression join(Expression delimiter)
      Creates an expression that joins the elements of this array expression into a string.
      Parameters:
      delimiter - The delimiter to use.
      Returns:
      A new Expression representing the join operation.
    • isNotNaN

      public final BooleanExpression isNotNaN()
      Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a Number).
      Returns:
      A new BooleanExpression representing the isNotNan operation.
    • logicalMaximum

      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.
      Parameters:
      others - Optional additional expressions or literals.
      Returns:
      A new Expression representing the logical maximum operation.
    • logicalMinimum

      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.
      Parameters:
      others - Optional additional expressions or literals.
      Returns:
      A new Expression representing the logical minimum operation.
    • round

      public final Expression round()
      Creates an expression that rounds this numeric expression to nearest integer.

      Rounds away from zero in halfway cases.

      Returns:
      A new Expression representing an integer result from the round operation.
    • roundToPrecision

      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.
      Parameters:
      decimalPlace - The number of decimal places to round.
      Returns:
      A new Expression representing the round operation.
    • roundToPrecision

      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.
      Parameters:
      decimalPlace - The number of decimal places to round.
      Returns:
      A new Expression representing the round operation.
    • trunc

      public final Expression trunc()
      Creates an expression that truncates this numeric expression to an integer.
      Returns:
      A new Expression representing the trunc operation.
    • truncToPrecision

      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.
      Parameters:
      decimalPlace - The number of decimal places to truncate.
      Returns:
      A new Expression representing the trunc operation.
    • truncToPrecision

      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.
      Parameters:
      decimalPlace - The number of decimal places to truncate.
      Returns:
      A new Expression representing the trunc operation.
    • ceil

      public final Expression ceil()
      Creates an expression that returns the smallest integer that isn't less than this numeric expression.
      Returns:
      A new Expression representing an integer result from the ceil operation.
    • floor

      public final Expression floor()
      Creates an expression that returns the largest integer that isn't less than this numeric expression.
      Returns:
      A new Expression representing an integer result from the floor operation.
    • pow

      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.
      Parameters:
      exponent - The numeric power to raise this numeric expression.
      Returns:
      A new Expression representing a numeric result from raising this numeric expression to the power of exponent.
    • pow

      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.
      Parameters:
      exponent - The numeric power to raise this numeric expression.
      Returns:
      A new Expression representing a numeric result from raising this numeric expression to the power of exponent.
    • abs

      public final Expression abs()
      Creates an expression that returns the absolute value of this numeric expression.
      Returns:
      A new Expression representing the numeric result of the absolute value operation.
    • exp

      public final Expression exp()
      Creates an expression that returns Euler's number e raised to the power of this numeric expression.
      Returns:
      A new Expression representing the numeric result of the exponentiation.
    • ln

      public final Expression ln()
      Creates an expression that returns the natural logarithm (base e) of this numeric expression.
      Returns:
      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:
      A new Expression representing the numeric result of the base 10 logarithm.
    • arraySum

      public Expression arraySum()
      Creates an expression that returns the sum of the elements of this array expression.
      Returns:
      A new Expression representing the sum of the elements of the array.
    • sqrt

      public final Expression sqrt()
      Creates an expression that returns the square root of this numeric expression.
      Returns:
      A new Expression representing the numeric result of the square root operation.
    • add

      public final Expression add(Object other)
      Creates an expression that adds this numeric expression to another numeric expression.
      Parameters:
      other - Numeric expression to add.
      Returns:
      A new Expression representing the addition operation.
    • subtract

      public final Expression subtract(Object other)
      Creates an expression that subtracts a numeric expressions from this numeric expression.
      Parameters:
      other - Constant to subtract.
      Returns:
      A new Expression representing the subtract operation.
    • multiply

      public final Expression multiply(Object other)
      Creates an expression that multiplies this numeric expression with another numeric expression.
      Parameters:
      other - Numeric expression to multiply.
      Returns:
      A new Expression representing the multiplication operation.
    • divide

      public final Expression divide(Object other)
      Creates an expression that divides this numeric expression by another numeric expression.
      Parameters:
      other - Numeric expression to divide this numeric expression by.
      Returns:
      A new Expression representing the division operation.
    • mod

      public final Expression mod(Object other)
      Creates an expression that calculates the modulo (remainder) of dividing this numeric expressions by another numeric expression.
      Parameters:
      other - The numeric expression to divide this expression by.
      Returns:
      A new Expression representing the modulo operation.
    • equal

      public final BooleanExpression equal(Object other)
      Creates an expression that checks if this expression is equal to a value.
      Parameters:
      other - The value to compare to.
      Returns:
      A new BooleanExpression representing the equality comparison.
    • notEqual

      public final BooleanExpression notEqual(Object other)
      Creates an expression that checks if this expression is not equal to a value.
      Parameters:
      other - The value to compare to.
      Returns:
      A new BooleanExpression representing the inequality comparison.
    • greaterThan

      public final BooleanExpression greaterThan(Object other)
      Creates an expression that checks if this expression is greater than a value.
      Parameters:
      other - The value to compare to.
      Returns:
      A new BooleanExpression representing the greater than comparison.
    • greaterThanOrEqual

      public final BooleanExpression greaterThanOrEqual(Object other)
      Creates an expression that checks if this expression is greater than or equal to a value.
      Parameters:
      other - The value to compare to.
      Returns:
      A new BooleanExpression representing the greater than or equal to comparison.
    • lessThan

      public final BooleanExpression lessThan(Object other)
      Creates an expression that checks if this expression is less than a value.
      Parameters:
      other - The value to compare to.
      Returns:
      A new BooleanExpression representing the less than comparison.
    • lessThanOrEqual

      public final BooleanExpression lessThanOrEqual(Object other)
      Creates an expression that checks if this expression is less than or equal to a value.
      Parameters:
      other - The value to compare to.
      Returns:
      A new BooleanExpression representing the less than or equal to comparison.
    • equalAny

      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.
      Parameters:
      other - The values to check against.
      Returns:
      A new BooleanExpression representing the 'IN' comparison.
    • notEqualAny

      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.
      Parameters:
      other - The values to check against.
      Returns:
      A new BooleanExpression representing the 'NOT IN' comparison.
    • charLength

      public final Expression charLength()
      Creates an expression that calculates the character length of this string expression in UTF8.
      Returns:
      A new Expression representing the charLength operation.
    • 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:
      A new Expression representing the length of the string in bytes.
    • 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:
      A new Expression representing the length of the expression.
    • like

      public final BooleanExpression like(Object pattern)
      Creates an expression that performs a case-sensitive wildcard string comparison.
      Parameters:
      pattern - The pattern to search for. You can use "%" as a wildcard character.
      Returns:
      A new BooleanExpression representing the like operation.
    • regexContains

      public final BooleanExpression regexContains(Object pattern)
      Creates an expression that checks if this string expression contains a specified regular expression as a substring.
      Parameters:
      pattern - The regular expression to use for the search.
      Returns:
      A new BooleanExpression representing the contains regular expression comparison.
    • regexFind

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      pattern - The regular expression to search for.
      Returns:
      A new Expression representing the regular expression find function.
    • regexFindAll

      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](https://github.com/google/re2/wiki/Syntax) regular expression syntax.

      Parameters:
      pattern - The regular expression to search for.
      Returns:
      A new Expression that evaluates to a list of matched substrings.
    • regexMatch

      public final BooleanExpression regexMatch(Object pattern)
      Creates an expression that checks if this string expression matches a specified regular expression.
      Parameters:
      pattern - The regular expression to use for the match.
      Returns:
      A new BooleanExpression representing the regular expression match comparison.
    • stringContains

      public final BooleanExpression stringContains(Object substring)
      Creates an expression that checks if this string expression contains a specified substring.
      Parameters:
      substring - The expression representing the substring to search for.
      Returns:
      A new BooleanExpression representing the contains comparison.
    • startsWith

      public final BooleanExpression startsWith(Object prefix)
      Creates an expression that checks if this string expression starts with a given prefix.
      Parameters:
      prefix - The prefix string expression to check for.
      Returns:
      A new Expression representing the the 'starts with' comparison.
    • endsWith

      public final BooleanExpression endsWith(Object suffix)
      Creates an expression that checks if this string expression ends with a given suffix.
      Parameters:
      suffix - The suffix string expression to check for.
      Returns:
      A new Expression representing the 'ends with' comparison.
    • substring

      public final Expression substring(Object index, Object length)
      Creates an expression that returns a substring of the given string.
      Parameters:
      index - The starting index of the substring.
      length - The length of the substring.
      Returns:
      A new Expression representing the substring.
    • toLower

      public final Expression toLower()
      Creates an expression that converts this string expression to lowercase.
      Returns:
      A new Expression representing the lowercase string.
    • toUpper

      public final Expression toUpper()
      Creates an expression that converts this string expression to uppercase.
      Returns:
      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:
      A new Expression representing the trimmed string.
    • trimValue

      public Expression trimValue(String characters)
      Creates an expression that removes specified characters from the beginning and end of this string or blob expression.
      Parameters:
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • trimValue

      public Expression trimValue(Expression characters)
      Creates an expression that removes specified characters from the beginning and end of this string or blob expression.
      Parameters:
      characters - The expression representing the characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrim

      public Expression ltrim()
      Creates an expression that removes whitespace from the beginning of this string or blob expression.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrimValue

      public Expression ltrimValue(String characters)
      Creates an expression that removes the specified set of characters from the beginning of this string or blob expression.
      Parameters:
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • ltrimValue

      public Expression ltrimValue(Expression characters)
      Creates an expression that removes the specified characters or bytes from the beginning of this string or blob expression.
      Parameters:
      characters - The expression representing the characters or bytes to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrim

      public Expression rtrim()
      Creates an expression that removes whitespace from the end of this string or blob expression.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrimValue

      public Expression rtrimValue(String characters)
      Creates an expression that removes the specified set of characters from the end of this string or blob expression.
      Parameters:
      characters - The characters to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • rtrimValue

      public Expression rtrimValue(Expression characters)
      Creates an expression that removes the specified characters or bytes from the end of this string or blob expression.
      Parameters:
      characters - The expression representing the characters or bytes to remove.
      Returns:
      A new Expression representing the trimmed string or blob.
    • stringRepeat

      public Expression stringRepeat(Number repetitions)
      Creates an expression that repeats a string or blob a specified number of times.
      Parameters:
      repetitions - The number of times to repeat the string or blob.
      Returns:
      A new Expression representing the repeated string or blob.
    • stringRepeat

      public Expression stringRepeat(Expression repetitions)
      Creates an expression that repeats a string or blob a specified number of times.
      Parameters:
      repetitions - The expression representing the number of times to repeat.
      Returns:
      A new Expression representing the repeated string or blob.
    • stringReplaceAll

      public Expression stringReplaceAll(String find, String replacement)
      Creates an expression that replaces all occurrences of a substring or byte sequence.
      Parameters:
      find - The match pattern.
      replacement - The replacement string/bytes.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceAll

      public Expression stringReplaceAll(Expression find, Expression replacement)
      Creates an expression that replaces all occurrences of a substring or byte sequence.
      Parameters:
      find - The expression representing the match pattern.
      replacement - The expression representing the replacement value.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceOne

      public Expression stringReplaceOne(String find, String replacement)
      Creates an expression that replaces the first occurrence of a substring or byte sequence.
      Parameters:
      find - The match pattern.
      replacement - The replacement string/bytes.
      Returns:
      A new Expression representing the replaced value.
    • stringReplaceOne

      public Expression stringReplaceOne(Expression find, Expression replacement)
      Creates an expression that replaces the first occurrence of a substring or byte sequence.
      Parameters:
      find - The expression representing the match pattern.
      replacement - The expression representing the replacement value.
      Returns:
      A new Expression representing the replaced value.
    • stringIndexOf

      public Expression stringIndexOf(String search)
      Creates an expression that returns the index of the first occurrence of a substring or bytes.
      Parameters:
      search - The search pattern.
      Returns:
      A new Expression representing the index.
    • stringIndexOf

      public Expression stringIndexOf(Expression search)
      Creates an expression that returns the index of the first occurrence of a substring or bytes.
      Parameters:
      search - The expression representing the search pattern.
      Returns:
      A new Expression representing the index.
    • split

      public Expression split(Expression delimiter)
      Creates an expression that splits this string or blob expression by a delimiter.
      Parameters:
      delimiter - The delimiter to split by.
      Returns:
      A new Expression representing the split string or blob as an array.
    • split

      public Expression split(String delimiter)
      Creates an expression that splits this string or blob expression by a delimiter.
      Parameters:
      delimiter - The delimiter to split by.
      Returns:
      A new Expression representing the split string or blob as an array.
    • stringConcat

      public final Expression stringConcat(String... others)
      Creates an expression that concatenates string expressions and string constants together.
      Parameters:
      others - The string expressions or string constants to concatenate.
      Returns:
      A new Expression representing the concatenated string.
    • stringConcat

      public final Expression stringConcat(Expression... others)
      Creates an expression that concatenates string expressions together.
      Parameters:
      others - The string expressions or string constants to concatenate.
      Returns:
      A new Expression representing the concatenated string.
    • mapGet

      public final Expression mapGet(Object key)
      Accesses a map (object) value using the provided key.
      Parameters:
      key - The key to access in the map.
      Returns:
      A new Expression representing the value associated with the given key in the map.
    • 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:
      A new BooleanExpression representing the isAbsent operation.
    • isNaN

      public final BooleanExpression isNaN()
      Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number).
      Returns:
      A new BooleanExpression representing the isNan operation.
    • isNull

      public final BooleanExpression isNull()
      Creates an expression that checks if tbe result of this expression is null.
      Returns:
      A new BooleanExpression representing the isNull operation.
    • isNotNull

      public final BooleanExpression isNotNull()
      Creates an expression that checks if tbe result of this expression is not null.
      Returns:
      A new BooleanExpression representing the isNotNull operation.
    • sum

      public final AggregateFunction sum()
      Creates an aggregation that calculates the sum of this numeric expression across multiple stage inputs.
      Returns:
      A new AggregateFunction representing the sum aggregation.
    • average

      public final AggregateFunction average()
      Creates an aggregation that calculates the average (mean) of this numeric expression across multiple stage inputs.
      Returns:
      A new AggregateFunction representing the average aggregation.
    • minimum

      public final AggregateFunction minimum()
      Creates an aggregation that finds the minimum value of this expression across multiple stage inputs.
      Returns:
      A new AggregateFunction representing the minimum aggregation.
    • maximum

      public final AggregateFunction maximum()
      Creates an aggregation that finds the maximum value of this expression across multiple stage inputs.
      Returns:
      A new AggregateFunction representing the maximum aggregation.
    • count

      public final AggregateFunction count()
      Creates an aggregation that counts the number of stage inputs with valid evaluations of the this expression.
      Returns:
      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:
      A new AggregateFunction representing the count distinct aggregation.
    • first

      public final AggregateFunction first()
      Creates an aggregation that finds the first value of this expression across multiple stage inputs.
      Returns:
      A new AggregateFunction representing the first aggregation.
    • last

      public final AggregateFunction last()
      Creates an aggregation that finds the last value of this expression across multiple stage inputs.
      Returns:
      A new AggregateFunction representing the last aggregation.
    • 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:
      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:
      A new AggregateFunction representing the array_agg_distinct aggregation.
    • ascending

      public final Ordering ascending()
      Create an Ordering that sorts documents in ascending order based on value of this expression
      Returns:
      A new Ordering object with ascending sort by this expression.
    • descending

      public final Ordering descending()
      Create an Ordering that sorts documents in descending order based on value of this expression
      Returns:
      A new Ordering object with descending sort by this expression.
    • as

      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.

      Parameters:
      alias - The alias to assign to this expression.
      Returns:
      A new AliasedExpression that wraps this expression and associates it with the provided alias.
    • mapMerge

      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:
      secondMap - Map expression that will be merged.
      otherMaps - Additional maps to merge.
      Returns:
      A new Expression representing the mapMerge operation.
    • mapRemove

      public final Expression mapRemove(Expression key)
      Creates an expression that removes a key from this map expression.
      Parameters:
      key - The name of the key to remove from this map expression.
      Returns:
      A new Expression that evaluates to a modified map.
    • mapRemove

      public final Expression mapRemove(String key)
      Creates an expression that removes a key from this map expression.
      Parameters:
      key - The name of the key to remove from this map expression.
      Returns:
      A new Expression that evaluates to a modified map.
    • mapSet

      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:
      key - The key to set.
      value - The value to set.
      moreKeyValues - Additional key-value pairs to set.
      Returns:
      A new Expression representing the map with the entries set.
    • mapSet

      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:
      key - The key to set.
      value - The value to set.
      moreKeyValues - Additional key-value pairs to set.
      Returns:
      A new Expression representing the map with the entries set.
    • 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:
      A new Expression representing the keys of the map.
    • 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:
      A new Expression representing the values of the map.
    • 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:
      A new Expression representing the entries of the map.
    • reverse

      public final Expression reverse()
      Creates an expression that reverses this expression, which must be a string, blob, or array.
      Returns:
      A new Expression representing the reversed value.
    • arrayConcat

      public final Expression arrayConcat(Expression... otherArrays)
      Creates an expression that concatenates a field's array value with other arrays.
      Parameters:
      otherArrays - Optional additional array expressions or array literals to concatenate.
      Returns:
      A new Expression representing the arrayConcat operation.
    • arrayFirst

      public final Expression arrayFirst()
      Returns the first element of an array.
      Returns:
      A new Expression representing the first element of the array.
    • arrayFirstN

      public final Expression arrayFirstN(int n)
      Returns the first n elements of an array.
      Parameters:
      n - The number of elements to return.
      Returns:
      A new Expression representing the first n elements of the array.
    • arrayFirstN

      public final Expression arrayFirstN(Expression n)
      Returns the first n elements of an array.
      Parameters:
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the first n elements of the array.
    • arrayLast

      public final Expression arrayLast()
      Returns the last element of an array.
      Returns:
      A new Expression representing the last element of the array.
    • arrayLastN

      public final Expression arrayLastN(int n)
      Returns the last n elements of an array.
      Parameters:
      n - The number of elements to return.
      Returns:
      A new Expression representing the last n elements of the array.
    • arrayLastN

      public final Expression arrayLastN(Expression n)
      Returns the last n elements of an array.
      Parameters:
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the last n elements of the array.
    • arrayMinimum

      public final Expression arrayMinimum()
      Returns the minimum value of an array.
      Returns:
      A new Expression representing the minimum value of the array.
    • arrayMinimumN

      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.

      Parameters:
      n - The number of elements to return.
      Returns:
      A new Expression representing the n minimum values of the array.
    • arrayMinimumN

      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.

      Parameters:
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the n minimum values of the array.
    • arrayMaximum

      public final Expression arrayMaximum()
      Returns the maximum value of an array.
      Returns:
      A new Expression representing the maximum value of the array.
    • arrayMaximumN

      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.

      Parameters:
      n - The number of elements to return.
      Returns:
      A new Expression representing the n maximum values of the array.
    • arrayMaximumN

      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.

      Parameters:
      n - The Expression evaluates to the number of elements to return.
      Returns:
      A new Expression representing the n maximum values of the array.
    • arrayIndexOf

      public final Expression arrayIndexOf(Object value)
      Returns the index of the first occurrence of a value in an array.
      Parameters:
      value - The value to search for.
      Returns:
      A new Expression representing the index.
    • arrayIndexOf

      public final Expression arrayIndexOf(Expression value)
      Returns the index of the first occurrence of a value in an array.
      Parameters:
      value - The value to search for.
      Returns:
      A new Expression representing the index.
    • arrayLastIndexOf

      public final Expression arrayLastIndexOf(Object value)
      Returns the index of the last occurrence of a value in an array.
      Parameters:
      value - The value to search for.
      Returns:
      A new Expression representing the last index.
    • arrayLastIndexOf

      public final Expression arrayLastIndexOf(Expression value)
      Returns the index of the last occurrence of a value in an array.
      Parameters:
      value - The value to search for.
      Returns:
      A new Expression representing the last index.
    • arrayIndexOfAll

      public final Expression arrayIndexOfAll(Object value)
      Returns all indices of a value in an array.
      Parameters:
      value - The value to search for.
      Returns:
      A new Expression representing the indices.
    • arrayIndexOfAll

      public final Expression arrayIndexOfAll(Expression value)
      Returns all indices of a value in an array.
      Parameters:
      value - The value to search for.
      Returns:
      A new Expression representing the indices.
    • arrayReverse

      public final Expression arrayReverse()
      Reverses the order of elements in the array.
      Returns:
      A new Expression representing the arrayReverse operation.
    • arrayFilter

      public final Expression arrayFilter(String alias, BooleanExpression filter)
      Filters this array based on a predicate.
      Parameters:
      alias - The alias for the current element in the filter expression.
      filter - The predicate boolean expression used to filter the elements.
      Returns:
      A new Expression representing the filtered array.
    • arrayTransform

      public final Expression arrayTransform(String elementAlias, Expression transform)
      Creates an expression that applies a provided transformation to each element in an array.
      Parameters:
      elementAlias - The alias for the current element in the transform expression.
      transform - The expression used to transform the elements.
      Returns:
      A new Expression representing the transformed array.
    • arrayTransformWithIndex

      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:
      elementAlias - The alias for the current element in the transform expression.
      indexAlias - The alias for the current index.
      transform - The expression used to transform the elements.
      Returns:
      A new Expression representing the transformed array.
    • arraySlice

      public final Expression arraySlice(int offset, int length)
      Returns a slice of this array.
      Parameters:
      offset - The starting index.
      length - The number of elements to return.
      Returns:
      A new Expression representing the array slice.
    • arraySlice

      public final Expression arraySlice(Expression offset, Expression length)
      Returns a slice of this array.
      Parameters:
      offset - The starting index expressed as an Expression.
      length - The number of elements to return expressed as an Expression.
      Returns:
      A new Expression representing the array slice.
    • arraySliceToEnd

      public final Expression arraySliceToEnd(int offset)
      Returns a slice of this array to its end.
      Parameters:
      offset - The starting index.
      Returns:
      A new Expression representing the array slice.
    • arraySliceToEnd

      public final Expression arraySliceToEnd(Expression offset)
      Returns a slice of this array to its end.
      Parameters:
      offset - The starting index expressed as an Expression.
      Returns:
      A new Expression representing the array slice.
    • arrayContains

      public final BooleanExpression arrayContains(Object element)
      Creates an expression that checks if array contains a specific element.
      Parameters:
      element - The element to search for in the array.
      Returns:
      A new BooleanExpression representing the arrayContains operation.
    • arrayContainsAll

      public final BooleanExpression arrayContainsAll(List<Object> values)
      Creates an expression that checks if array contains all the specified values.
      Parameters:
      values - The elements to check for in the array.
      Returns:
      A new BooleanExpression representing the arrayContainsAll operation.
    • arrayContainsAll

      public final BooleanExpression arrayContainsAll(Expression arrayExpression)
      Creates an expression that checks if array contains all elements of arrayExpression.
      Parameters:
      arrayExpression - The elements to check for in the array.
      Returns:
      A new BooleanExpression representing the arrayContainsAll operation.
    • arrayContainsAny

      public final BooleanExpression arrayContainsAny(List<Object> values)
      Creates an expression that checks if array contains any of the specified values.
      Parameters:
      values - The elements to check for in the array.
      Returns:
      A new BooleanExpression representing the arrayContainsAny operation.
    • arrayContainsAny

      public final BooleanExpression arrayContainsAny(Expression arrayExpression)
      Creates an expression that checks if array contains any elements of arrayExpression.
      Parameters:
      arrayExpression - The elements to check for in the array.
      Returns:
      A new BooleanExpression representing the arrayContainsAny operation.
    • arrayLength

      public final Expression arrayLength()
      Creates an expression that calculates the length of an array expression.
      Returns:
      A new Expression representing the length of the array.
    • arrayGet

      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.
      Parameters:
      offset - An Expression evaluating to the index of the element to return.
      Returns:
      A new Expression representing the arrayGet operation.
    • arrayGet

      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.
      Parameters:
      offset - An Expression evaluating to the index of the element to return.
      Returns:
      A new Expression representing the arrayOffset operation.
    • cosineDistance

      public final Expression cosineDistance(Expression vector)
      Calculates the Cosine distance between this and another vector expressions.
      Parameters:
      vector - The other vector (represented as an Expression) to compare against.
      Returns:
      A new Expression representing the cosine distance between the two vectors.
    • cosineDistance

      public final Expression cosineDistance(double[] vector)
      Calculates the Cosine distance between this vector expression and a vector literal.
      Parameters:
      vector - The other vector (as an array of doubles) to compare against.
      Returns:
      A new Expression representing the cosine distance between the two vectors.
    • dotProduct

      public final Expression dotProduct(Expression vector)
      Calculates the dot product distance between this and another vector expression.
      Parameters:
      vector - The other vector (represented as an Expression) to compare against.
      Returns:
      A new Expression representing the dot product distance between the two vectors.
    • dotProduct

      public final Expression dotProduct(double[] vector)
      Calculates the dot product distance between this vector expression and a vector literal.
      Parameters:
      vector - The other vector (as an array of doubles) to compare against.
      Returns:
      A new Expression representing the dot product distance between the two vectors.
    • euclideanDistance

      public final Expression euclideanDistance(Expression vector)
      Calculates the Euclidean distance between this and another vector expression.
      Parameters:
      vector - The other vector (represented as an Expression) to compare against.
      Returns:
      A new Expression representing the Euclidean distance between the two vectors.
    • euclideanDistance

      public final Expression euclideanDistance(double[] vector)
      Calculates the Euclidean distance between this vector expression and a vector literal.
      Parameters:
      vector - The other vector (as an array of doubles) to compare against.
      Returns:
      A new Expression representing the Euclidean distance between the two vectors.
    • vectorLength

      public final Expression vectorLength()
      Creates an expression that calculates the length (dimension) of a Firestore Vector.
      Returns:
      A new Expression representing the length (dimension) of the vector.
    • 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:
      A new Expression representing the 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:
      A new Expression representing the number of microseconds since epoch.
    • 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:
      A new Expression representing the timestamp.
    • 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:
      A new Expression representing the number of milliseconds since epoch.
    • 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:
      A new Expression representing the timestamp.
    • 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:
      A new Expression representing the number of seconds since epoch.
    • timestampAdd

      public final Expression timestampAdd(Expression unit, Expression amount)
      Creates an expression that adds a specified amount of time to this timestamp expression.
      Parameters:
      unit - The expression representing the unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The expression representing the amount of time to add.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampAdd

      public final Expression timestampAdd(String unit, long amount)
      Creates an expression that adds a specified amount of time to this timestamp expression.
      Parameters:
      unit - The unit of time to add. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to add.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampSubtract

      public final Expression timestampSubtract(Expression unit, Expression amount)
      Creates an expression that subtracts a specified amount of time to this timestamp expression.
      Parameters:
      unit - The expression representing the unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The expression representing the amount of time to subtract.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampSubtract

      public final Expression timestampSubtract(String unit, long amount)
      Creates an expression that subtracts a specified amount of time to this timestamp expression.
      Parameters:
      unit - The unit of time to subtract. Valid units include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      amount - The amount of time to subtract.
      Returns:
      A new Expression representing the resulting timestamp.
    • timestampTruncate

      public final Expression timestampTruncate(String granularity)
      Creates an expression that truncates this timestamp expression to a specified granularity.
      Parameters:
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncate

      public final Expression timestampTruncate(Expression granularity)
      Creates an expression that truncates this timestamp expression to a specified granularity.
      Parameters:
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". Defaults to "UTC" if not specified.
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The timezone to use for truncation. Valid values are from the TZ database (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1".
      Returns:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      granularity - The granularity to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The 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:
      A new Expression representing the truncated timestamp.
    • timestampTruncateWithTimezone

      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:
      granularity - The granularity expression to truncate to. Valid values are "microsecond", "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", "isoweek", "month", "quarter", "year", and "isoyear".
      timezone - The 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:
      A new Expression representing the truncated timestamp.
    • timestampDiff

      public final Expression timestampDiff(Expression start, Expression unit)
      Calculates the difference between this timestamp and another timestamp.
      Parameters:
      start - The starting timestamp expression.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampDiff

      public final Expression timestampDiff(Expression start, String unit)
      Calculates the difference between this timestamp and another timestamp.
      Parameters:
      start - The starting timestamp expression.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampDiff

      public final Expression timestampDiff(String startFieldName, String unit)
      Calculates the difference between this timestamp and another timestamp.
      Parameters:
      startFieldName - The name of the field containing the starting timestamp.
      unit - The unit of time for the difference. Valid values include "microsecond", "millisecond", "second", "minute", "hour" and "day".
      Returns:
      A new Expression representing the difference.
    • timestampExtract

      public final Expression timestampExtract(Expression part)
      Creates an expression that extracts a specified part from this timestamp expression.
      Parameters:
      part - The 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:
      A new Expression representing the extracted part.
    • timestampExtract

      public final Expression timestampExtract(String part)
      Creates an expression that extracts a specified part from this timestamp expression.
      Parameters:
      part - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • timestampExtractWithTimezone

      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:
      part - The 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 - The 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:
      A new Expression representing the extracted part.
    • exists

      public final BooleanExpression exists()
      Creates an expression that checks if this expression evaluates to a name of the field that exists.
      Returns:
      A new Expression representing the exists check.
    • ifError

      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.
      Parameters:
      catchExpr - The catch expression that will be evaluated and returned if the this expression produces an error.
      Returns:
      A new Expression representing the ifError operation.
    • ifError

      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.
      Parameters:
      catchValue - The value that will be returned if this expression produces an error.
      Returns:
      A new Expression representing the ifError operation.
    • isError

      public final BooleanExpression isError()
      Creates an expression that checks if this expression produces an error.
      Returns:
      A new BooleanExpression representing the `isError` check.
    • documentId

      public final Expression documentId()
      Creates an expression that returns the document ID from this path expression.
      Returns:
      A new Expression representing the documentId operation.
    • collectionId

      public final Expression collectionId()
      Creates an expression that returns the collection ID from this path expression.
      Returns:
      A new Expression representing the collectionId operation.
    • parent

      public final Expression parent()
      Creates an expression that returns the parent document of a document reference.
      Returns:
      A new Expression representing the parent operation.
    • type

      public final Expression type()
      Creates an expression that returns a string indicating the type of the value this expression evaluates to.
      Returns:
      A new Expression representing the type operation.
    • 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:
      An Expression representing the current document.
    • variable

      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));
       
      Parameters:
      name - The name of the variable to retrieve.
      Returns:
      An Expression representing the variable's value.
    • getField

      public Expression getField(String key)
      Accesses a field/property of the expression that evaluates to a Map or Document.
      Parameters:
      key - The key of the field to access.
      Returns:
      An Expression representing the value of the field.
    • getField

      public Expression getField(Expression keyExpression)
      Retrieves the value of a specific field from the document evaluated by this expression.
      Parameters:
      keyExpression - The expression evaluating to the key to access.
      Returns:
      A new Expression representing the field value.
    • getField

      public static Expression getField(String fieldName, String key)
      Accesses a field/property of a document field using the provided key.
      Parameters:
      fieldName - The field name of the map or document field.
      key - The key of the field to access.
      Returns:
      An Expression representing the value of the field.
    • getField

      public static Expression getField(Expression expression, Expression keyExpression)
      Accesses a field/property of the expression using the provided keyExpression.
      Parameters:
      expression - The expression evaluating to a Map or Document.
      keyExpression - The expression evaluating to the key.
      Returns:
      A new Expression representing the value of the field.
    • getField

      public static Expression getField(String fieldName, Expression keyExpression)
      Accesses a field/property of a document field using the provided keyExpression.
      Parameters:
      fieldName - The field name of the map or document field.
      keyExpression - The expression evaluating to the key.
      Returns:
      A new Expression representing the value of the field.
    • getField

      public static Expression getField(Expression expression, String key)
      Accesses a field/property of the expression that evaluates to a Map or Document.
      Parameters:
      expression - The expression evaluating to a map/document.
      key - The key of the field to access.
      Returns:
      An Expression representing the value of the field.
    • isType

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

      Parameters:
      type - The type to check for.
      Returns:
      A new BooleanExpression that evaluates to true if the expression's result is of the given type, false otherwise.