aws

Amazon DynamoDB now supports real-time vector search at any scale | Amazon Web Services (opens in new tab)

Amazon DynamoDB now offers native vector search, allowing applications to store embeddings beside operational data and query them without a separate vector database. The serverless service provides single-digit millisecond latency, 99%+ recall, horizontal scaling, and support for trillions of vectors. This removes synchronization pipelines, data movement, and additional infrastructure for applications already built on DynamoDB.

Native Vector Search in DynamoDB

  • Embeddings are stored directly in DynamoDB as lists of floating-point numbers.
  • Similarity searches use the SearchVectors API and return up to 100 ranked results.
  • Vector indexes scale horizontally without storage limits or servers to manage.
  • Pricing follows DynamoDB’s pay-per-request model.
  • Common use cases include:
    • Agent memory
    • Retrieval-augmented generation
    • Recommendations
    • Personalized experiences
    • Anomaly detection

Supported Search Capabilities

  • Supports vectors with up to 4,096 dimensions.
  • Offers three distance functions:
    • Cosine: Useful for semantic text similarity.
    • Euclidean: Useful when vector magnitude is meaningful.
    • Dot product: Useful when both direction and magnitude affect relevance.
  • Supports optional partition keys to distribute data and scope searches.
  • Supports inline exact-match filters, but not range operators such as BETWEEN or BEGINS_WITH.
  • Search results can include operational attributes through index projections.

Adding Embeddings to an Existing Table

  • Generate embeddings with a model such as Amazon Bedrock Titan Text Embeddings, Cohere Embed, or OpenAI embeddings.
  • Store them in a new attribute, such as descriptionEmbedding, using UpdateItem or other AWS tooling.
  • No new DynamoDB data type or schema migration is required because vectors use the existing List and Number types.

Creating and Using a Vector Index

  • Create a vector index on the embedding attribute.
  • Configure:
    • Index name
    • Vector attribute
    • Embedding dimensions
    • Distance function
    • Optional partition key
    • Filter attributes
  • Generate a query embedding with the same model used for stored data.
  • Call SearchVectors with the query vector, result count, partition key, and filters.
  • Scores depend on the distance function:
    • Lower scores indicate greater similarity for Cosine and Euclidean distance.
    • Higher scores indicate greater similarity for Dot product.

Example: Product Catalog Search

  • A ProductCatalog table stores product details such as productId, name, description, category, marketplace, and price.
  • Product descriptions receive embeddings stored in descriptionEmbedding.
  • A ProductDescriptionIndex can use:
    • marketplace as the partition key
    • category as an inline filter
    • Cosine distance for semantic matching
  • A query such as “lightweight running shoes for summer” can return the five most relevant footwear products in the US marketplace, along with attributes such as name and price.

DynamoDB vector search is best suited to applications whose operational data already resides in DynamoDB and need semantic retrieval without operating a second database or synchronization system.