Skip to content

create_index

create_index(
    index_name: IndexName,
    data_type: DataType,
    dimension: Dimension,
    distance_metric: DistanceMetric,
    *,
    config_overrides: Optional[S3VectorsClientConfig] = None,
    vector_bucket_name: Optional[VectorBucketName] = None,
    vector_bucket_arn: Optional[VectorBucketArn] = None,
    metadata_configuration: Optional[MetadataConfiguration] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
    tags: Optional[TagsMap] = None,
) -> CreateIndexOutput

Creates a vector index within a vector bucket. To specify the vector bucket, you must use either the vector bucket name or the vector bucket Amazon Resource Name (ARN).

Permissions

You must have the s3vectors:CreateIndex permission to use this operation.

You must have the s3vectors:TagResource permission in addition to s3vectors:CreateIndex permission to create a vector index with tags.

Parameters:

  • vector_bucket_name (Optional[VectorBucketName], default: None ) –

    The name of the vector bucket to create the vector index in.

  • vector_bucket_arn (Optional[VectorBucketArn], default: None ) –

    The Amazon Resource Name (ARN) of the vector bucket to create the vector index in.

  • index_name (IndexName) –

    The name of the vector index to create.

  • data_type (DataType) –

    The data type of the vectors to be inserted into the vector index.

  • dimension (Dimension) –

    The dimensions of the vectors to be inserted into the vector index.

  • distance_metric (DistanceMetric) –

    The distance metric to be used for similarity search.

  • metadata_configuration (Optional[MetadataConfiguration], default: None ) –

    The metadata configuration for the vector index.

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

    The encryption configuration for a vector index. By default, if you don't specify, all new vectors in the vector index will use the encryption configuration of the vector bucket.

  • tags (Optional[TagsMap], default: None ) –

    An array of user-defined tags that you would like to apply to the vector index that you are creating. A tag is a key-value pair that you apply to your resources. Tags can help you organize, track costs, and control access to resources. For more information, see Tagging for cost allocation or attribute-based access control (ABAC).

    You must have the s3vectors:TagResource permission in addition to s3vectors:CreateIndex permission to create a vector index with tags.

Raises:

  • AccessDeniedException –

    Access denied.

  • InternalServerException –

    The request failed due to an internal server error.

  • RequestTimeoutException –

    The request timed out. Retry your request.

  • TooManyRequestsException –

    The request was denied due to request throttling.

  • ValidationException –

    The requested action isn't valid.

  • ConflictException –

    The request failed because a vector bucket name or a vector index name already exists. Vector bucket names must be unique within your Amazon Web Services account for each Amazon Web Services Region. Vector index names must be unique within your vector bucket. Choose a different vector bucket name or vector index name, and try again.

  • NotFoundException –

    The request was rejected because the specified resource can't be found.

  • ServiceQuotaExceededException –

    Your request exceeds a service quota.

  • ServiceUnavailableException –

    The service is unavailable. Wait briefly and retry your request. If it continues to fail, increase your waiting time between retries.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_s3vectors/_services/s3_vectors.py
def create_index(
    self,
    index_name: "capo_s3vectors.types.index_name.IndexName",
    data_type: "capo_s3vectors.types.data_type.DataType",
    dimension: "capo_s3vectors.types.dimension.Dimension",
    distance_metric: "capo_s3vectors.types.distance_metric.DistanceMetric",
    *,
    config_overrides: Optional[S3VectorsClientConfig] = None,
    vector_bucket_name: Optional[
        "capo_s3vectors.types.vector_bucket_name.VectorBucketName"
    ] = None,
    vector_bucket_arn: Optional[
        "capo_s3vectors.types.vector_bucket_arn.VectorBucketArn"
    ] = None,
    metadata_configuration: Optional[
        "capo_s3vectors.types.metadata_configuration.MetadataConfiguration"
    ] = None,
    encryption_configuration: Optional[
        "capo_s3vectors.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
    tags: Optional["capo_s3vectors.types.tags_map.TagsMap"] = None,
) -> "capo_s3vectors.types.create_index_output.CreateIndexOutput":
    """<p>Creates a vector index within a vector bucket. To specify the vector bucket, you must use either the vector bucket name or the vector bucket Amazon Resource Name (ARN).</p> <dl> <dt>Permissions</dt> <dd> <p>You must have the <code>s3vectors:CreateIndex</code> permission to use this operation.</p> <p>You must have the <code>s3vectors:TagResource</code> permission in addition to <code>s3vectors:CreateIndex</code> permission to create a vector index with tags.</p> </dd> </dl>

    Args:
        vector_bucket_name: <p>The name of the vector bucket to create the vector index in. </p>
        vector_bucket_arn: <p>The Amazon Resource Name (ARN) of the vector bucket to create the vector index in.</p>
        index_name: <p>The name of the vector index to create. </p>
        data_type: <p>The data type of the vectors to be inserted into the vector index. </p>
        dimension: <p>The dimensions of the vectors to be inserted into the vector index. </p>
        distance_metric: <p>The distance metric to be used for similarity search. </p>
        metadata_configuration: <p>The metadata configuration for the vector index. </p>
        encryption_configuration: <p>The encryption configuration for a vector index. By default, if you don't specify, all new vectors in the vector index will use the encryption configuration of the vector bucket.</p>
        tags: <p>An array of user-defined tags that you would like to apply to the vector index that you are creating. A tag is a key-value pair that you apply to your resources. Tags can help you organize, track costs, and control access to resources. For more information, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/tagging.html">Tagging for cost allocation or attribute-based access control (ABAC)</a>.</p> <note> <p>You must have the <code>s3vectors:TagResource</code> permission in addition to <code>s3vectors:CreateIndex</code> permission to create a vector index with tags.</p> </note>

    Raises:
        capo_s3vectors.errors.access_denied_exception.AccessDeniedException: <p>Access denied.</p>
        capo_s3vectors.errors.internal_server_exception.InternalServerException: <p>The request failed due to an internal server error.</p>
        capo_s3vectors.errors.request_timeout_exception.RequestTimeoutException: <p>The request timed out. Retry your request.</p>
        capo_s3vectors.errors.too_many_requests_exception.TooManyRequestsException: <p>The request was denied due to request throttling.</p>
        capo_s3vectors.errors.validation_exception.ValidationException: <p>The requested action isn't valid.</p>
        capo_s3vectors.errors.conflict_exception.ConflictException: <p>The request failed because a vector bucket name or a vector index name already exists. Vector bucket names must be unique within your Amazon Web Services account for each Amazon Web Services Region. Vector index names must be unique within your vector bucket. Choose a different vector bucket name or vector index name, and try again.</p>
        capo_s3vectors.errors.not_found_exception.NotFoundException: <p>The request was rejected because the specified resource can't be found.</p>
        capo_s3vectors.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Your request exceeds a service quota. </p>
        capo_s3vectors.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unavailable. Wait briefly and retry your request. If it continues to fail, increase your waiting time between retries.</p>
        capo_s3vectors.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_s3vectors.types.create_index_input.CreateIndexInput]",
    ) -> OperationResponse[
        "capo_s3vectors.types.create_index_output.CreateIndexOutput"
    ]:
        import capo_s3vectors._operations.s3_vectors.create_index

        output, http_response = (
            capo_s3vectors._operations.s3_vectors.create_index.create_index(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateIndex")
    )
    input_: capo_s3vectors.types.create_index_input.CreateIndexInput = {
        "index_name": index_name,
        "data_type": data_type,
        "dimension": dimension,
        "distance_metric": distance_metric,
    }
    if vector_bucket_name is not None:
        input_["vector_bucket_name"] = vector_bucket_name
    if vector_bucket_arn is not None:
        input_["vector_bucket_arn"] = vector_bucket_arn
    if metadata_configuration is not None:
        input_["metadata_configuration"] = metadata_configuration
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output