- HTTP request
- Path parameters
- Request body
- Response body
- Authorization Scopes
- AggregationQuery
- Aggregation
- Count
- AggregationResultBatch
- AggregationResult
- Try it!
Runs an aggregation query.
HTTP request
POST https://datastore.googleapis.com/v1beta3/projects/{projectId}:runAggregationQuery
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
projectId |
Required. The ID of the project against which to make the request. |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "partitionId": { object ( |
Fields | |
---|---|
partitionId |
Entities are partitioned into subsets, identified by a partition ID. Queries are scoped to a single partition. This partition ID is normalized with the standard default context partition ID. |
readOptions |
The options for this query. |
Union field query_type . The type of query. query_type can be only one of the following: |
|
aggregationQuery |
The query to run. |
gqlQuery |
The GQL query to run. This query must be an aggregation query. |
Response body
If successful, the response body contains data with the following structure:
The response for Datastore.RunAggregationQuery
.
JSON representation |
---|
{ "batch": { object ( |
Fields | |
---|---|
batch |
A batch of aggregation results. Always present. |
query |
The parsed form of the |
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/datastore
https://www.googleapis.com/auth/cloud-platform
For more information, see the Authentication Overview.
AggregationQuery
Datastore query for running an aggregation over a Query
.
JSON representation |
---|
{ "aggregations": [ { object ( |
Fields | |
---|---|
aggregations[] |
Optional. Series of aggregations to apply over the results of the Requires:
|
Union field query_type . The base query to aggregate over. query_type can be only one of the following: |
|
nestedQuery |
Nested query for aggregation |
Aggregation
Defines a aggregation that produces a single result.
JSON representation |
---|
{ "alias": string, // Union field |
Fields | |
---|---|
alias |
Optional. Optional name of the property to store the result of the aggregation. If not provided, Datastore will pick a default name following the format
becomes:
Requires:
|
Union field operator . The type of aggregation to perform, required. operator can be only one of the following: |
|
count |
Count aggregator. |
Count
Count of entities that match the query.
The COUNT(*)
aggregation function operates on the entire entity so it does not require a field reference.
JSON representation |
---|
{ "upTo": string } |
Fields | |
---|---|
upTo |
Optional. Optional constraint on the maximum number of entities to count. This provides a way to set an upper bound on the number of entities to scan, limiting latency and cost. Unspecified is interpreted as no bound. If a zero value is provided, a count result of zero should always be expected. High-Level Example:
Requires:
|
AggregationResultBatch
A batch of aggregation results produced by an aggregation query.
JSON representation |
---|
{ "aggregationResults": [ { object ( |
Fields | |
---|---|
aggregationResults[] |
The aggregation results for this batch. |
moreResults |
The state of the query after the current batch. Only COUNT(*) aggregations are supported in the initial launch. Therefore, expected result type is limited to |
readTime |
Read timestamp this batch was returned from. In a single transaction, subsequent query result batches for the same query can have a greater timestamp. Each batch's read timestamp is valid for all preceding batches. A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: |
AggregationResult
The result of a single bucket from a Datastore aggregation query.
The keys of aggregateProperties
are the same for all results in an aggregation query, unlike entity queries which can have different fields present for each result.
JSON representation |
---|
{
"aggregateProperties": {
string: {
object ( |
Fields | |
---|---|
aggregateProperties |
The result of the aggregation functions, ex: The key is the An object containing a list of |