listVectors method
List vectors in the specified vector index. To specify the vector index, you can either use both the vector bucket name and the vector index name, or use the vector index Amazon Resource Name (ARN).
ListVectors operations proceed sequentially; however, for
faster performance on a large number of vectors in a vector index,
applications can request a parallel ListVectors operation by
providing the segmentCount and segmentIndex
parameters.
- Permissions
-
You must have the
s3vectors:ListVectorspermission to use this operation. Additional permissions are required based on the request parameters you specify:-
With only
s3vectors:ListVectorspermission, you can list vector keys whenreturnDataandreturnMetadataare both set to false or not specified.. -
If you set
returnDataorreturnMetadatato true, you must have boths3vectors:ListVectorsands3vectors:GetVectorspermissions. The request fails with a403 Forbiddenerror if you request vector data or metadata without thes3vectors:GetVectorspermission.
-
With only
May throw AccessDeniedException.
May throw NotFoundException.
May throw ServiceUnavailableException.
Parameter indexArn :
The Amazon resource Name (ARN) of the vector index.
Parameter indexName :
The name of the vector index.
Parameter maxResults :
The maximum number of vectors to return on a page.
If you don't specify maxResults, the ListVectors
operation uses a default value of 500.
If the processed dataset size exceeds 1 MB before reaching the
maxResults value, the operation stops and returns the vectors
that are retrieved up to that point, along with a nextToken
that you can use in a subsequent request to retrieve the next set of
results.
Parameter nextToken :
Pagination token from a previous request. The value of this field is empty
for an initial request.
Parameter returnData :
If true, the vector data of each vector will be included in the response.
The default value is false.
Parameter returnMetadata :
If true, the metadata associated with each vector will be included in the
response. The default value is false.
Parameter segmentCount :
For a parallel ListVectors request, segmentCount
represents the total number of vector segments into which the
ListVectors operation will be divided. The value of
segmentCount corresponds to the number of application workers
that will perform the parallel ListVectors operation. For
example, if you want to use four application threads to list vectors in a
vector index, specify a segmentCount value of 4.
If you specify a segmentCount value of 1, the
ListVectors operation will be sequential rather than
parallel.
If you specify segmentCount, you must also specify
segmentIndex.
Parameter segmentIndex :
For a parallel ListVectors request, segmentIndex
is the index of the segment from which to list vectors in the current
request. It identifies an individual segment to be listed by an
application worker.
Segment IDs are zero-based, so the first segment is always 0. For example,
if you want to use four application threads to list vectors in a vector
index, then the first thread specifies a segmentIndex value
of 0, the second thread specifies 1, and so on.
The value of segmentIndex must be less than the value
provided for segmentCount.
If you provide segmentIndex, you must also provide
segmentCount.
Parameter vectorBucketName :
The name of the vector bucket.
Implementation
Future<ListVectorsOutput> listVectors({
String? indexArn,
String? indexName,
int? maxResults,
String? nextToken,
bool? returnData,
bool? returnMetadata,
int? segmentCount,
int? segmentIndex,
String? vectorBucketName,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
1000,
);
_s.validateNumRange(
'segmentCount',
segmentCount,
1,
16,
);
_s.validateNumRange(
'segmentIndex',
segmentIndex,
0,
15,
);
final $payload = <String, dynamic>{
if (indexArn != null) 'indexArn': indexArn,
if (indexName != null) 'indexName': indexName,
if (maxResults != null) 'maxResults': maxResults,
if (nextToken != null) 'nextToken': nextToken,
if (returnData != null) 'returnData': returnData,
if (returnMetadata != null) 'returnMetadata': returnMetadata,
if (segmentCount != null) 'segmentCount': segmentCount,
if (segmentIndex != null) 'segmentIndex': segmentIndex,
if (vectorBucketName != null) 'vectorBucketName': vectorBucketName,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/ListVectors',
exceptionFnMap: _exceptionFns,
);
return ListVectorsOutput.fromJson(response);
}