createIndex method
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:CreateIndexpermission to use this operation.You must have the
s3vectors:TagResourcepermission in addition tos3vectors:CreateIndexpermission to create a vector index with tags.
May throw ConflictException.
May throw NotFoundException.
May throw ServiceQuotaExceededException.
May throw ServiceUnavailableException.
Parameter dataType :
The data type of the vectors to be inserted into the vector index.
Parameter dimension :
The dimensions of the vectors to be inserted into the vector index.
Parameter distanceMetric :
The distance metric to be used for similarity search.
Parameter indexName :
The name of the vector index to create.
Parameter encryptionConfiguration :
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.
Parameter metadataConfiguration :
The metadata configuration for the vector index.
Parameter tags :
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).
Parameter vectorBucketArn :
The Amazon Resource Name (ARN) of the vector bucket to create the vector
index in.
Parameter vectorBucketName :
The name of the vector bucket to create the vector index in.
Implementation
Future<CreateIndexOutput> createIndex({
required DataType dataType,
required int dimension,
required DistanceMetric distanceMetric,
required String indexName,
EncryptionConfiguration? encryptionConfiguration,
MetadataConfiguration? metadataConfiguration,
Map<String, String>? tags,
String? vectorBucketArn,
String? vectorBucketName,
}) async {
_s.validateNumRange(
'dimension',
dimension,
1,
4096,
isRequired: true,
);
final $payload = <String, dynamic>{
'dataType': dataType.value,
'dimension': dimension,
'distanceMetric': distanceMetric.value,
'indexName': indexName,
if (encryptionConfiguration != null)
'encryptionConfiguration': encryptionConfiguration,
if (metadataConfiguration != null)
'metadataConfiguration': metadataConfiguration,
if (tags != null) 'tags': tags,
if (vectorBucketArn != null) 'vectorBucketArn': vectorBucketArn,
if (vectorBucketName != null) 'vectorBucketName': vectorBucketName,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/CreateIndex',
exceptionFnMap: _exceptionFns,
);
return CreateIndexOutput.fromJson(response);
}