Can you use AWS DynamoDB as a vector database?
No, DynamoDB is a key-value store and does not support vector search. However, by using SvectorDB, you can index your DynamoDB tables in real-time and perform vector searches on the indexed data. This integration leverages DynamoDB streams and a Lambda function to keep your vector index up-to-date automatically.
How to Set Up Real-Time Vector Indexing with DynamoDB and SvectorDB
We’ve created a one-click deploy CloudFormation stack that makes it easy to set up real-time vector indexing for your DynamoDB tables using SvectorDB. Follow the steps below to deploy the stack and start indexing your data.
For the source code and CloudFormation template, visit the DynamoDB Indexer GitHub repository.
Step-by-Step Guide
-
Download and Prepare the Lambda Code
Download the latest compiled code from the releases page or compile the source code yourself with the following commands:
cd code
npm install
npm run buildOnce compiled, upload the code to an S3 bucket in your AWS account.
-
Enable SvectorDB CloudFormation Extensions
Ensure that the SvectorDB CloudFormation extensions are enabled in your account. You can do this by following the instructions in the SvectorDB documentation.
-
Enable DynamoDB Streams
Make sure that your source DynamoDB table has DynamoDB streams enabled. This is necessary for the Lambda function to subscribe to changes in the table and update the index in real-time.
-
Deploy the CloudFormation Stack
Use the provided CloudFormation template to deploy the stack. You'll need to provide the following parameters:
DynamoDbStreamArn
: The ARN of the DynamoDB stream to subscribe to.SvectorDbIntegrationId
: The ID in your SvectorDB dashboard for the CloudFormation integration. Ensure your AWS account ID is added to the allowed accounts list.VectorDimension
: The dimension of the vector index.VectorDistanceMetric
: The distance metric to use for the index.VectorFieldToIndex
: The name of the field in the source table to use as the document's vector. This field must be a list of numbers.DatabaseType
: The tier of database to create (e.g., sandbox for the free tier).LambdaBucket
: The name of the S3 bucket where the Lambda code is stored.LambdaKey
: The key of the Lambda code in the S3 bucket.
After deploying the stack, the index will be updated in real-time as records are added, updated, or deleted from the source table.
-
Perform Vector Searches
Use the index to perform nearest neighbor searches. Check out the
code/src/demo.ts
file for an example of how to use the index for this purpose.
Additional Resources
For more information on setting up and using the vector index, visit the SvectorDB Quick Start guide. This guide provides comprehensive instructions and examples to help you get the most out of your SvectorDB integration.
By following these steps, you can effectively use SvectorDB to index and search your DynamoDB tables in real-time, combining the scalability of DynamoDB with the powerful vector search capabilities of SvectorDB.
Ready to experience the difference?