getStatistics method

Future<GetStatisticsResponse> getStatistics({
  1. required String queryString,
  2. String? aggregationField,
  3. String? indexName,
  4. String? queryVersion,
})

Returns the count, average, sum, minimum, maximum, sum of squares, variance, and standard deviation for the specified aggregated field. If the aggregation field is of type String, only the count statistic is returned.

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

Parameter queryString : The query used to search. You can specify "*" for the query string to get the count of all indexed things in your AWS account.

Parameter aggregationField : The aggregation field name.

Parameter indexName : The name of the index to search. The default value is AWS_Things.

Parameter queryVersion : The version of the query used to search.

Implementation

Future<GetStatisticsResponse> getStatistics({
  required String queryString,
  String? aggregationField,
  String? indexName,
  String? queryVersion,
}) async {
  ArgumentError.checkNotNull(queryString, 'queryString');
  _s.validateStringLength(
    'queryString',
    queryString,
    1,
    1152921504606846976,
    isRequired: true,
  );
  _s.validateStringLength(
    'aggregationField',
    aggregationField,
    1,
    1152921504606846976,
  );
  _s.validateStringLength(
    'indexName',
    indexName,
    1,
    128,
  );
  final $payload = <String, dynamic>{
    'queryString': queryString,
    if (aggregationField != null) 'aggregationField': aggregationField,
    if (indexName != null) 'indexName': indexName,
    if (queryVersion != null) 'queryVersion': queryVersion,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/indices/statistics',
    exceptionFnMap: _exceptionFns,
  );
  return GetStatisticsResponse.fromJson(response);
}