getPercentiles method

Future<GetPercentilesResponse> getPercentiles({
  1. required String queryString,
  2. String? aggregationField,
  3. String? indexName,
  4. List<double>? percents,
  5. String? queryVersion,
})

Groups the aggregated values that match the query into percentile groupings. The default percentile groupings are: 1,5,25,50,75,95,99, although you can specify your own when you call GetPercentiles. This function returns a value for each percentile group specified (or the default percentile groupings). The percentile group "1" contains the aggregated field value that occurs in approximately one percent of the values that match the query. The percentile group "5" contains the aggregated field value that occurs in approximately five percent of the values that match the query, and so on. The result is an approximation, the more values that match the query, the more accurate the percentile values.

Requires permission to access the GetPercentiles 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 queryString : The search query string.

Parameter aggregationField : The field to aggregate.

Parameter indexName : The name of the index to search.

Parameter percents : The percentile groups returned.

Parameter queryVersion : The query version.

Implementation

Future<GetPercentilesResponse> getPercentiles({
  required String queryString,
  String? aggregationField,
  String? indexName,
  List<double>? percents,
  String? queryVersion,
}) async {
  final $payload = <String, dynamic>{
    'queryString': queryString,
    if (aggregationField != null) 'aggregationField': aggregationField,
    if (indexName != null) 'indexName': indexName,
    if (percents != null) 'percents': percents,
    if (queryVersion != null) 'queryVersion': queryVersion,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri: '/indices/percentiles',
    exceptionFnMap: _exceptionFns,
  );
  return GetPercentilesResponse.fromJson(response);
}