updateIndex method

Future<void> updateIndex({
  1. required String id,
  2. required String indexName,
  3. Object? indexSchema,
})

Updates an existing index in an OpenSearch Serverless collection. This operation allows you to modify the index schema, including adding new fields or changing field mappings. You can also enable automatic semantic enrichment ingestion and search. For more information, see About automatic semantic enrichment.

May throw InternalServerException. May throw ResourceNotFoundException. May throw ValidationException.

Parameter id : The unique identifier of the collection containing the index to update.

Parameter indexName : The name of the index to update.

Parameter indexSchema : The updated JSON schema definition for the index, including field mappings and settings.

Implementation

Future<void> updateIndex({
  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.UpdateIndex'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'id': id,
      'indexName': indexName,
      if (indexSchema != null) 'indexSchema': indexSchema,
    },
  );
}