createIndex method

Future<CreateIndexResponse> createIndex({
  1. required String domainName,
  2. required String indexName,
  3. required Object indexSchema,
})

Creates an OpenSearch index with optional automatic semantic enrichment for specified text fields. Automatic semantic enrichment enables semantic search capabilities without requiring machine learning expertise, improving search relevance by up to 20% by understanding search intent and contextual meaning beyond keyword matching. The semantic enrichment process has zero impact on search latency as sparse encodings are stored directly within the index during indexing. For more information, see Automatic semantic enrichment.

May throw AccessDeniedException. May throw DependencyFailureException. May throw DisabledOperationException. May throw InternalException. May throw ResourceAlreadyExistsException. May throw ResourceNotFoundException. May throw ThrottlingException. May throw ValidationException.

Parameter indexName : The name of the index to create. Must be between 1 and 255 characters and follow OpenSearch naming conventions.

Parameter indexSchema : The JSON schema defining index mappings, settings, and semantic enrichment configuration. The schema specifies which text fields should be automatically enriched for semantic search capabilities and includes OpenSearch index configuration parameters.

Implementation

Future<CreateIndexResponse> createIndex({
  required String domainName,
  required String indexName,
  required Object indexSchema,
}) async {
  final $payload = <String, dynamic>{
    'IndexName': indexName,
    'IndexSchema': indexSchema,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/2021-01-01/opensearch/domain/${Uri.encodeComponent(domainName)}/index',
    exceptionFnMap: _exceptionFns,
  );
  return CreateIndexResponse.fromJson(response);
}