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.

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 search query.

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 {
  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/cardinality',
    exceptionFnMap: _exceptionFns,
  );
  return GetCardinalityResponse.fromJson(response);
}