getBucketsAggregation method

Future<GetBucketsAggregationResponse> getBucketsAggregation({
  1. required String aggregationField,
  2. required BucketsAggregationType bucketsAggregationType,
  3. required String queryString,
  4. String? indexName,
  5. String? queryVersion,
})

Aggregates on indexed data with search queries pertaining to particular fields.

Requires permission to access the GetBucketsAggregation action.

May throw IndexNotReadyException. May throw InternalFailureException. May throw InvalidAggregationException. May throw InvalidQueryException. May throw InvalidRequestException. May throw ResourceNotFoundException. May throw ServiceUnavailableException. May throw ThrottlingException. May throw UnauthorizedException.

Parameter aggregationField : The aggregation field.

Parameter bucketsAggregationType : The basic control of the response shape and the bucket aggregation type to perform.

Parameter queryString : The search query string.

Parameter indexName : The name of the index to search.

Parameter queryVersion : The version of the query.

Implementation

Future<GetBucketsAggregationResponse> getBucketsAggregation({
  required String aggregationField,
  required BucketsAggregationType bucketsAggregationType,
  required String queryString,
  String? indexName,
  String? queryVersion,
}) async {
  final $payload = <String, dynamic>{
    'aggregationField': aggregationField,
    'bucketsAggregationType': bucketsAggregationType,
    'queryString': queryString,
    if (indexName != null) 'indexName': indexName,
    if (queryVersion != null) 'queryVersion': queryVersion,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/indices/buckets',
    exceptionFnMap: _exceptionFns,
  );
  return GetBucketsAggregationResponse.fromJson(response);
}