termsEnum method
Discover terms in the index that match a partial String https://www.elastic.co/guide/en/elasticsearch/reference/8.1/search-terms-enum.html
Implementation
Future<TermsEnumResult> termsEnum({
String? index,
String? type,
required String field,
String? string,
bool? caseInsensitive,
int? size,
}) async {
final path = [
if (index != null) index,
if (type != null) type,
'_terms_enum',
];
final map = {
'field': field ,
if (string != null) 'string': string,
if (caseInsensitive != null) 'case_insensitive': caseInsensitive,
if (size != null) 'size': size,
};
final rs = await _transport
.send(Request('POST', path, bodyMap: map));
rs.throwIfStatusNotOK(message: 'Failed to retrieve term enum for $field.');
final body = rs.bodyAsMap;
final termsResults = (body['terms']?.whereType<String>()?.toList() ?? <String>[]) as List<String> ;
return TermsEnumResult(
termsResults
);
}