Skip to content

Performs a vector similarity search on a vector index associated with an Amazon DynamoDB table, and returns the most similar items sorted by similarity score based on the distance function configured for the index

Description

Performs a vector similarity search on a vector index associated with an Amazon DynamoDB table, and returns the most similar items sorted by similarity score based on the distance function configured for the index.

Score interpretation depends on the distance function:

  • COSINE - Returns the items with the k smallest scores. Scores range from 0 (identical) to 2 (opposite). Lower scores indicate higher similarity.
  • EUCLIDEAN - Returns the items with the k smallest scores. Scores represent the Euclidean distance between vectors. Lower scores indicate higher similarity.
  • DOT_PRODUCT - Returns the items with the k highest scores. Higher scores indicate higher similarity.

Usage

dynamodb_search_vectors(TableName, IndexName, ReturnConsumedCapacity,
  ExpressionAttributeNames, ExpressionAttributeValues,
  ProjectionExpression, SearchVector, SearchConditionExpression, TopK)

Arguments

  • TableName

[required] The name or Amazon Resource Name (ARN) of the table containing the vector index.

  • IndexName

[required] The name of the vector index to search. The index must be in the ACTIVE state.

  • ReturnConsumedCapacity

Determines the level of detail about either provisioned or on-demand throughput consumption that is returned in the response:

  • INDEXES - The response includes the aggregate ConsumedCapacity for the operation, together with ConsumedCapacity for each table and secondary index that was accessed.

    Note that some operations, such as get_item and batch_get_item, do not access any indexes at all. In these cases, specifying INDEXES will only return ConsumedCapacity information for table(s). - TOTAL - The response includes only the aggregate ConsumedCapacity for the operation. - NONE - No ConsumedCapacity details are included in the response.

  • ExpressionAttributeNames

One or more substitution tokens for attribute names in an expression. Use the # character in an expression to dereference an attribute name.

  • ExpressionAttributeValues

One or more values that can be substituted in an expression. Use the : character in an expression to dereference an attribute value.

  • ProjectionExpression

A string that identifies one or more attributes to retrieve from the index. Separate attribute names with commas. If not specified, the operation returns all attributes projected into the vector index.

Only attributes projected into the vector index can be retrieved.

  • SearchVector

[required] The search vector to compare against the indexed vectors. Each element is a 32-bit IEEE-754 floating point number, provided in DynamoDB list format.

The number of dimensions must match the number of dimensions configured for the vector index.

  • SearchConditionExpression

A condition expression used to filter the vector search results. The expression can reference attributes defined in the vector index search schema, including HASH and INLINE_FILTER key elements.

Only the equality operator (=) is supported for HASH attributes. Comparison and range operators are supported for INLINE_FILTER attributes. Only top-level attributes from the search schema can be referenced.

  • TopK

[required] The number of most similar results to return.

Value

A list with the following syntax:

list(
  ConsumedCapacity = list(
    VectorSearchRequestBytes = 123.0,
    VectorWriteRequestBytes = 123.0
  ),
  SearchResults = list(
    list(
      Item = list(
        list(
          S = "string",
          N = "string",
          B = raw,
          SS = list(
            "string"
          ),
          NS = list(
            "string"
          ),
          BS = list(
            raw
          ),
          M = list(
            list()
          ),
          L = list(
            list()
          ),
          NULL = TRUE|FALSE,
          BOOL = TRUE|FALSE
        )
      ),
      Score = 123.0
    )
  )
)

Request syntax

svc$search_vectors(
  TableName = "string",
  IndexName = "string",
  ReturnConsumedCapacity = "INDEXES"|"TOTAL"|"NONE",
  ExpressionAttributeNames = list(
    "string"
  ),
  ExpressionAttributeValues = list(
    list(
      S = "string",
      N = "string",
      B = raw,
      SS = list(
        "string"
      ),
      NS = list(
        "string"
      ),
      BS = list(
        raw
      ),
      M = list(
        list()
      ),
      L = list(
        list()
      ),
      NULL = TRUE|FALSE,
      BOOL = TRUE|FALSE
    )
  ),
  ProjectionExpression = "string",
  SearchVector = list(
    list(
      S = "string",
      N = "string",
      B = raw,
      SS = list(
        "string"
      ),
      NS = list(
        "string"
      ),
      BS = list(
        raw
      ),
      M = list(
        list()
      ),
      L = list(
        list()
      ),
      NULL = TRUE|FALSE,
      BOOL = TRUE|FALSE
    )
  ),
  SearchConditionExpression = "string",
  TopK = 123
)