AggregateField

public abstract classAggregateField

Known direct subclasses
AggregateField.AverageAggregateField

Represents an "average" aggregation that can be performed by Firestore.

AggregateField.CountAggregateField

Represents a "count" aggregation that can be performed by Firestore.

AggregateField.SumAggregateField

Represents a "sum" aggregation that can be performed by Firestore.


Represents an aggregation that can be performed by Firestore.

Summary

Nested types

Represents an "average" aggregation that can be performed by Firestore.

Represents a "count" aggregation that can be performed by Firestore.

Represents a "sum" aggregation that can be performed by Firestore.

Public fields

final @NonNullString
final @NonNullString

Public methods

static @NonNullAggregateField.AverageAggregateField

Create anAverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

static @NonNullAggregateField.AverageAggregateField

Create anAverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

static @NonNullAggregateField.CountAggregateField

Create aCountAggregateField object that can be used to compute the count of documents in the result set of a query.

boolean
equals(Object other)

Returns true if the given object is equal to this object.

int

Calculates and returns the hash code for this object.

static @NonNullAggregateField.SumAggregateField

Create aSumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

static @NonNullAggregateField.SumAggregateField
sum(@NonNullFieldPath fieldPath)

Create aSumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

Public fields

alias

public final @NonNullString alias

operator

public final @NonNullString operator

Public methods

average

public static @NonNullAggregateField.AverageAggregateField average(@NonNullString field)

Create anAverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

The result of an average operation will always be a double or NaN.

  • Averaging over zero documents or fields will result in a double value representing NaN.
  • Averaging over NaN will result in a double value representing NaN.
Parameters
@NonNullString field

Specifies the field to average across the result set.

Returns
@NonNullAggregateField.AverageAggregateField

The `AverageAggregateField` object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

average

public static @NonNullAggregateField.AverageAggregateField average(@NonNullFieldPath fieldPath)

Create anAverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

The result of an average operation will always be a double or NaN.

  • Averaging over zero documents or fields will result in a double value representing NaN.
  • Averaging over NaN will result in a double value representing NaN.
Parameters
@NonNullFieldPath fieldPath

Specifies the field to average across the result set.

Returns
@NonNullAggregateField.AverageAggregateField

The `AverageAggregateField` object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

count

public static @NonNullAggregateField.CountAggregateField count()

Create aCountAggregateField object that can be used to compute the count of documents in the result set of a query.

The result of a count operation will always be a 64-bit integer value.

Returns
@NonNullAggregateField.CountAggregateField

The `CountAggregateField` object that can be used to compute the count of documents in the result set of a query.

equals

public boolean equals(Object other)

Returns true if the given object is equal to this object. Two `AggregateField` objects are considered equal if they have the same operator and operate on the same field.

hashCode

public int hashCode()

Calculates and returns the hash code for this object.

sum

public static @NonNullAggregateField.SumAggregateField sum(@NonNullString field)

Create aSumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

The result of a sum operation will always be a 64-bit integer value, a double, or NaN.

  • Summing over zero documents or fields will result in 0L.
  • Summing over NaN will result in a double value representing NaN.
  • A sum that overflows the maximum representable 64-bit integer value will result in a double return value. This may result in lost precision of the result.
  • A sum that overflows the maximum representable double value will result in a double return value representing infinity.
Parameters
@NonNullString field

Specifies the field to sum across the result set.

Returns
@NonNullAggregateField.SumAggregateField

The `SumAggregateField` object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

sum

public static @NonNullAggregateField.SumAggregateField sum(@NonNullFieldPath fieldPath)

Create aSumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

The result of a sum operation will always be a 64-bit integer value, a double, or NaN.

  • Summing over zero documents or fields will result in 0L.
  • Summing over NaN will result in a double value representing NaN.
  • A sum that overflows the maximum representable 64-bit integer value will result in a double return value. This may result in lost precision of the result.
  • A sum that overflows the maximum representable double value will result in a double return value representing infinity.
Parameters
@NonNullFieldPath fieldPath

Specifies the field to sum across the result set.

Returns
@NonNullAggregateField.SumAggregateField

The `SumAggregateField` object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-21 UTC.