Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

Build a Serverless Search Engine with DynamoDB Vector Search and AWS CDK

DynamoDB native vector indexes let you run semantic search beside operational data with SearchVectors. Here is how the architecture works, how to read scores, how to size the index, and when OpenSearch Serverless is the better fit.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes, you can run semantic search without a separate vector database. DynamoDB offers native vector indexes, so you store embeddings next to your operational items and query them with the SearchVectors operation. The architecture is straightforward. Two details decide whether it works well for you: how you read the scores, which depends on the distance function configured on the index, and how you provision the index, because the CDK path for DynamoDB vector indexes still needs verification before you ship it. This guide covers both, along with the point where OpenSearch Serverless becomes the better choice.

How the pieces fit together

The pattern separates three jobs: preparing content, storing vectors beside your data, and running similarity queries. In practice the flow looks like this:

As an Amazon Associate I earn from qualifying purchases.

  1. Define the searchable unit. Decide what one item is (a support article, a product description, a chat memory, a document chunk) and which fields you need to return with each match. Those returned fields are the ones you will project into the index later.
  2. Generate embeddings. Send the text to an embedding model. AWS documentation names Amazon Bedrock and other model providers as possible sources of foundation models. It does not recommend a specific embedding model, and no quality, latency, or cost figure for a particular model is established in the sources this guide relies on, so test candidates against your own content.
  3. Choose the dimension count. Pick the smallest dimension count that still meets your relevance needs. Storage grows with dimensions (see the storage section below).
  4. Write items with vector attributes. Store each item in the DynamoDB table with its embedding attribute, plus any partition-key attribute you plan to scope searches by.
  5. Create the vector index on the table and wait until it reports ACTIVE. Searches against an index that is not active do not run.
  6. Embed the query with the same model you used for the items, then call SearchVectors with the table name, the index name, the search vector, and a top-k count.
  7. Hydrate the results. Use the returned items to show results. If a field you need is not projected into the index, fetch it from the base table by key.

Because the vectors live in the same table as your operational data, there is no separate replication pipeline to run for this pattern. Your application writes once, and the index reflects items that carry valid vector attributes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Reading SearchVectors results correctly

The AWS CLI reference describes SearchVectors as a similarity search against a vector index on a DynamoDB table. It returns the most similar items sorted by a similarity score, and the meaning of that score depends on the distance function configured for the index. The request includes the table, the index, a search vector, and the number of results to return (top-k).

#1 Best Overall

The most common mistake is assuming a higher score always means a closer match. It does not. The direction depends on the metric:

Distance function Which results are returned How to read the score
Cosine The k smallest scores Lower is closer. Scores range from 0 (identical) to 2 (opposite).
Euclidean The k smallest scores Lower is closer.
Dot product The k highest scores Higher is closer.

Sort your display logic from the index configuration, not from a general rule. If you change the distance function, your ranking thresholds must change with it.

Index storage and design choices

Vector-index storage is separate from base-table storage, and your design choices change the size of that index. AWS documentation identifies three levers.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Dimensions

The vector portion of the index stores 32-bit floating-point values, so vector storage grows with the number of dimensions. AWS gives one comparison in its storage guidance: a 1,536-dimension vector uses roughly four times the vector storage of a 384-dimension vector. That is an illustration of how dimensions scale, not an estimate of your bill. The guidance page does not state a publication year for this example, so confirm the current figure in the storage documentation before you size a production index.

Projections

Projected attributes add storage on top of the vectors. The projection type you choose sets how much of each item is copied into the index:

Projection type What is copied into the index Storage impact
KEYS_ONLY Key attributes only Lowest
INCLUDE Keys plus the non-key attributes you specify Depends on the attributes listed
ALL Every attribute on the item Highest

AWS recommends projecting only the attributes your code reads directly from search results. Everything else should come from the base table by key.

Which items enter the index

Only items with valid vector attributes are replicated to the vector index. If the index defines a partition-key attribute, items must also carry that attribute. An item missing either one is absent from search results, with no error on the write. This is the most common cause of “my new items don’t show up,” so check it first (see the checklist below).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Partition scoping for tenants, users, and sessions

AWS describes DynamoDB vector search for retrieval-augmented generation (RAG) and agent memory, and it supports partition scoping by a tenant, user, or session key. Scoping keeps one customer’s memories or documents out of another customer’s results, and it reduces the candidate set that each query considers. Design the partition key before you create the index, because it determines which items are eligible.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Provisioning with AWS CDK: what is verified

AWS CDK defines your infrastructure in code and provisions the supported AWS resources it describes. For this architecture, the verified and unverified parts are different, so keep them separate in your project:

  • Verified: The AWS CDK v2 API reference includes an L1 CfnCollection construct for Amazon OpenSearch Serverless collections, with a vector option in its properties. Provisioning an OpenSearch Serverless collection also requires an encryption policy, as the CDK Python CfnCollection reference notes.
  • Not established: A definitive CDK resource schema for creating a DynamoDB vector index. Do not copy CDK code for the DynamoDB index from an unverified source. Confirm the resource type and property names in the current CDK API reference, then check the matching CloudFormation resource definition before you deploy.
  • Not established: The IAM permissions needed to create the index and call SearchVectors. Grant the minimum set that the current DynamoDB API documentation lists for those actions, then test with a non-production role.

Until the DynamoDB index resource is confirmed, you can still create the table and its data-writing logic in CDK, then create the vector index through the supported path that your account and Region expose. Record the index name in your stack outputs so application code can reference it.

DynamoDB vector search or OpenSearch Serverless

The choice comes down to what the query has to do beyond similarity. The table below compares the two options on the axes that the documentation actually distinguishes. It does not declare a winner, and it does not replace a workload test.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Requirement DynamoDB native vector index OpenSearch Serverless
Semantic similarity over data already in DynamoDB Designed for this case, with vectors stored beside operational items Supported, but requires a separate collection and a way to keep it in sync
Full-text or hybrid ranking Not described as a capability in the sources reviewed AWS points to OpenSearch integration for full-text, analytics, and hybrid search
Filtering, aggregations, geospatial or nested queries Not described as a capability in the sources reviewed Documented
Distance metrics Cosine, Euclidean, and dot product, as configured on the index Euclidean, cosine, and dot product
Replication pipeline None needed for the vector pattern DynamoDB-to-OpenSearch Zero-ETL integration is an option when you need the wider feature set
Index storage and service cost Not established here; check current pricing Not established here; check current pricing

Use DynamoDB native vector search when semantic retrieval is the main job, your data already lives in DynamoDB, and you want fewer moving parts. Move to OpenSearch Serverless when users need keyword relevance alongside semantic results, faceted analytics, or the broader query set that OpenSearch provides.

Before you deploy: checks and common failures

  • Confirm Region support. Region availability for DynamoDB vector indexes and SearchVectors was not established in the sources reviewed for this guide. Check the current AWS Regional services list for your target Region before you design around it.
  • Index not active. Searches fail or return nothing until the index is ACTIVE. Poll its status after creation.
  • Missing vectors in results. Check that the item has a valid vector attribute and the partition-key attribute the index requires.
  • Odd ranking. Confirm the distance function on the index, then apply the correct sort direction from the table above.
  • Missing fields in results. A field that is not projected will not appear in the search response. Add it to the INCLUDE list, or fetch it from the base table.
  • Cost surprises. Storage scales with dimensions and projected attributes. No workload price, latency, recall, or throughput figure is established in the sources, so measure these with your own data and current AWS pricing.

Build the search path against a small dataset first. Check score direction, partition scoping, and projected fields before you scale the index.

“

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.