getCardinality method

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

Returns the approximate count of unique values that match the query.

Requires permission to access the GetCardinality 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 queryVersion : The query version.

Implementation

Future<GetCardinalityResponse> getCardinality({
  required String queryString,
  String? aggregationField,
  String? indexName,
  String? queryVersion,
}) async {
  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/cardinality',
    exceptionFnMap: _exceptionFns,
  );
  return GetCardinalityResponse.fromJson(response);
}