createIndex method
Creates an index within an OpenSearch Serverless collection. Unlike other OpenSearch indexes, indexes created by this API are automatically configured to conduct automatic semantic enrichment ingestion and search. For more information, see About automatic semantic enrichment in the OpenSearch User Guide.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ValidationException.
Parameter id :
The unique identifier of the collection in which to create the index.
Parameter indexName :
The name of the index to create. Index names must be lowercase and can't
begin with underscores (_) or hyphens (-).
Parameter indexSchema :
The JSON schema definition for the index, including field mappings and
settings.
Implementation
Future<void> createIndex({
required String id,
required String indexName,
Object? indexSchema,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'OpenSearchServerless.CreateIndex'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'id': id,
'indexName': indexName,
if (indexSchema != null) 'indexSchema': indexSchema,
},
);
}