This sends a RunAggregationQuery RPC and then returns a generator
which consumes each document returned in the stream of
RunAggregationQueryResponse messages.
If a transaction is used and it already has write operations added,
this method cannot be used (i.e. read-after-write is not allowed).
Parameters
Name
Description
retry
Optional[google.api_core.retry.Retry]
Designation of what errors, if any, should be retried. Defaults to a system-specified policy.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class AggregationQuery (2.21.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.21.0 (latest)](/python/docs/reference/firestore/latest/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.20.2](/python/docs/reference/firestore/2.20.2/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.19.0](/python/docs/reference/firestore/2.19.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.18.0](/python/docs/reference/firestore/2.18.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.17.2](/python/docs/reference/firestore/2.17.2/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.16.1](/python/docs/reference/firestore/2.16.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.15.0](/python/docs/reference/firestore/2.15.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.14.0](/python/docs/reference/firestore/2.14.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.13.1](/python/docs/reference/firestore/2.13.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.12.0](/python/docs/reference/firestore/2.12.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.11.1](/python/docs/reference/firestore/2.11.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.10.1](/python/docs/reference/firestore/2.10.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.9.1](/python/docs/reference/firestore/2.9.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.8.0](/python/docs/reference/firestore/2.8.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.7.3](/python/docs/reference/firestore/2.7.3/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.6.1](/python/docs/reference/firestore/2.6.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.5.3](/python/docs/reference/firestore/2.5.3/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.4.0](/python/docs/reference/firestore/2.4.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.3.4](/python/docs/reference/firestore/2.3.4/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.2.0](/python/docs/reference/firestore/2.2.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.1.3](/python/docs/reference/firestore/2.1.3/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [2.0.2](/python/docs/reference/firestore/2.0.2/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.9.2](/python/docs/reference/firestore/1.9.2/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.8.1](/python/docs/reference/firestore/1.8.1/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.7.0](/python/docs/reference/firestore/1.7.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.6.2](/python/docs/reference/firestore/1.6.2/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.5.0](/python/docs/reference/firestore/1.5.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.4.0](/python/docs/reference/firestore/1.4.0/google.cloud.firestore_v1.aggregation.AggregationQuery)\n- [1.3.0](/python/docs/reference/firestore/1.3.0/google.cloud.firestore_v1.aggregation.AggregationQuery) \n\n AggregationQuery(nested_query)\n\nRepresents an aggregation query to the Firestore API.\n\nMethods\n-------\n\n### get\n\n get(\n transaction=None,\n retry: Union[retries.Retry, None, object] = _MethodDefault._DEFAULT_VALUE,\n timeout: float | None = None,\n *,\n explain_options: Optional[ExplainOptions] = None\n ) -\u003e QueryResultsList[AggregationResult]\n\nRuns the aggregation query.\n\nThis sends a `RunAggregationQuery` RPC and returns a list of\naggregation results in the stream of `RunAggregationQueryResponse`\nmessages.\n\n### stream\n\n stream(\n transaction: Optional[\"transaction.Transaction\"] = None,\n retry: Union[retries.Retry, None, object] = _MethodDefault._DEFAULT_VALUE,\n timeout: Optional[float] = None,\n *,\n explain_options: Optional[ExplainOptions] = None\n ) -\u003e StreamGenerator[List[AggregationResult]]\n\nRuns the aggregation query.\n\nThis sends a `RunAggregationQuery` RPC and then returns a generator\nwhich consumes each document returned in the stream of\n`RunAggregationQueryResponse` messages.\n\nIf a `transaction` is used and it already has write operations added,\nthis method cannot be used (i.e. read-after-write is not allowed)."]]