S3Vectors / Paginator / QueryVectors

QueryVectors

class S3Vectors.Paginator.QueryVectors
paginator = client.get_paginator('query_vectors')
paginate(**kwargs)

Creates an iterator that will paginate through responses from S3Vectors.Client.query_vectors().

See also: AWS API Documentation

Request Syntax

response_iterator = paginator.paginate(
    vectorBucketName='string',
    indexName='string',
    indexArn='string',
    topK=123,
    queryVector={
        'float32': [
            ...,
        ]
    },
    filter={...}|[...]|123|123.4|'string'|True|None,
    returnMetadata=True|False,
    returnDistance=True|False,
    PaginationConfig={
        'MaxItems': 123,
        'StartingToken': 'string'
    }
)
Parameters:
  • vectorBucketName (string) – The name of the vector bucket that contains the vector index.

  • indexName (string) – The name of the vector index that you want to query.

  • indexArn (string) – The ARN of the vector index that you want to query.

  • topK (integer) –

    [REQUIRED]

    The number of results to return for each query.

  • queryVector (dict) –

    [REQUIRED]

    The query vector. Ensure that the query vector has the same dimension as the dimension of the vector index that’s being queried. For example, if your vector index contains vectors with 384 dimensions, your query vector must also have 384 dimensions.

    Note

    This is a Tagged Union structure. Only one of the following top level keys can be set: float32.

    • float32 (list) –

      The vector data as 32-bit floating point numbers. The number of elements in this array must exactly match the dimension of the vector index where the operation is being performed.

      • (float) –

  • filter (document) – Metadata filter to apply during the query. For more information about metadata keys, see Metadata filtering in the Amazon S3 User Guide.

  • returnMetadata (boolean) – Indicates whether to include metadata in the response. The default value is false.

  • returnDistance (boolean) – Indicates whether to include the computed distance in the response. The default value is false.

  • PaginationConfig (dict) –

    A dictionary that provides parameters to control pagination.

    • MaxItems (integer) –

      The total number of items to return. If the total number of items available is more than the value specified in max-items then a NextToken will be provided in the output that you can use to resume pagination.

    • StartingToken (string) –

      A token to specify where to start paginating. This is the NextToken from a previous response.

Return type:

dict

Returns:

Response Syntax

{
    'vectors': [
        {
            'distance': ...,
            'key': 'string',
            'metadata': {...}|[...]|123|123.4|'string'|True|None
        },
    ],
    'distanceMetric': 'euclidean'|'cosine',
    'NextToken': 'string'
}

Response Structure

  • (dict) –

    • vectors (list) –

      The vectors in the approximate nearest neighbor search.

      • (dict) –

        The attributes of a vector in the approximate nearest neighbor search.

        • distance (float) –

          The measure of similarity between the vector in the response and the query vector.

        • key (string) –

          The key of the vector in the approximate nearest neighbor search.

        • metadata (document) –

          The metadata associated with the vector, if requested.

    • distanceMetric (string) –

      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.

    • NextToken (string) –

      A token to resume pagination.