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.

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 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 {
  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 (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);
}