Skip to content

create_index async

create_index(
    domain_name: DomainName,
    index_name: IndexName,
    index_schema: IndexSchema,
    *,
    config_overrides: Optional[AsyncOpenSearchClientConfig] = None,
) -> CreateIndexResponse

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.

Parameters:

  • index_name (IndexName) –

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

  • index_schema (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.

Raises:

Source code in docs_src/capo_opensearch/_services/async_open_search.py
async def create_index(
    self,
    domain_name: "capo_opensearch.types.domain_name.DomainName",
    index_name: "capo_opensearch.types.index_name.IndexName",
    index_schema: "capo_opensearch.types.index_schema.IndexSchema",
    *,
    config_overrides: Optional[AsyncOpenSearchClientConfig] = None,
) -> "capo_opensearch.types.create_index_response.CreateIndexResponse":
    """<p>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 <a href="https://docs.aws.amazon.com/opensearch-service/latest/developerguide/opensearch-semantic-enrichment.html">Automatic semantic enrichment</a>.</p>

    Args:
        index_name: <p>The name of the index to create. Must be between 1 and 255 characters and follow OpenSearch naming conventions.</p>
        index_schema: <p>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.</p>

    Raises:
        capo_opensearch.errors.access_denied_exception.AccessDeniedException: <p>An error occurred because you don't have permissions to access the resource.</p>
        capo_opensearch.errors.dependency_failure_exception.DependencyFailureException: <p>An exception for when a failure in one of the dependencies results in the service being unable to fetch details about the resource.</p>
        capo_opensearch.errors.disabled_operation_exception.DisabledOperationException: <p>An error occured because the client wanted to access an unsupported operation.</p>
        capo_opensearch.errors.internal_exception.InternalException: <p>Request processing failed because of an unknown error, exception, or internal failure.</p>
        capo_opensearch.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>An exception for creating a resource that already exists.</p>
        capo_opensearch.errors.resource_not_found_exception.ResourceNotFoundException: <p>An exception for accessing or deleting a resource that doesn't exist.</p>
        capo_opensearch.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling. Reduce the frequency of your requests and try again.</p>
        capo_opensearch.errors.validation_exception.ValidationException: <p>An exception for accessing or deleting a resource that doesn't exist.</p>
        capo_opensearch.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_opensearch.types.create_index_request.CreateIndexRequest]",
    ) -> AsyncOperationResponse[
        "capo_opensearch.types.create_index_response.CreateIndexResponse"
    ]:
        import capo_opensearch._operations.amazon_open_search_service.create_index

        (
            output,
            http_response,
        ) = await capo_opensearch._operations.amazon_open_search_service.create_index.async_create_index(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateIndex")
    )
    input_: capo_opensearch.types.create_index_request.CreateIndexRequest = {
        "domain_name": domain_name,
        "index_name": index_name,
        "index_schema": index_schema,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output