v1

latestOpenAPI 3.0.0Apache 2.0 License2026-07-1419110105.3 KB

Performs an approximate nearest neighbor search query in a vector index using a query vector. By default, it returns the keys of approximate nearest neighbors. You can optionally include the computed distance (between the query vector and each vector in the response) and metadata of each vector in the response.

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).

Permissions

You must have the s3vectors:QueryVectors permission to use this operation. Additional permissions are required based on the request parameters you specify:

  • With only s3vectors:QueryVectors permission, you can retrieve vector keys of approximate nearest neighbors and computed distances between these vectors. This permission is sufficient only when you don't set any metadata filters and don't request metadata (by keeping the returnMetadata parameter set to false or not specified).

  • If you specify a metadata filter or set returnMetadata to true, you must have both s3vectors:QueryVectors and s3vectors:GetVectors permissions. The request fails with a 403 Forbidden error if you request metadata filtering or metadata without the s3vectors:GetVectors permission.

post/QueryVectors

Request body

vectorBucketNamestring

The name of the vector bucket that contains the vector index.

indexNamestring

The name of the vector index that you want to query.

indexArnstring

The ARN of the vector index that you want to query.

topKinteger required

The number of results to return for each query.

filterobject

Metadata filter to apply during the query. For more information about metadata keys, see <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-vectors-metadata-filtering.html">Metadata filtering</a> in the <i>Amazon S3 User Guide</i>.

returnMetadataboolean

Indicates whether to include metadata in the response. The default value is <code>false</code>.

returnDistanceboolean

Indicates whether to include the computed distance in the response. The default value is <code>false</code>.

nextTokenstring

Pagination token from a previous request. The value of this field is empty for an initial request.

Response

Success

distanceMetric'euclidean' | 'cosine' required

The distance metric that was used for the similarity search calculation. This is the same distance metric that was configured for the vector index when it was created.

nextTokenstring

Pagination token to be used in the subsequent page request. The field is empty if no further pagination is required.