Lesson 2 of 4 Embeddings and Vector Stores

Choosing a Vector Store on AWS

This lesson describes the AWS vector stores, which differ in scale, query features, cost and integration with existing data, and when each fits.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe vector search in OpenSearch Service and OpenSearch Serverless.
  • Use pgvector on Aurora PostgreSQL and RDS.
  • Identify S3 Vectors, Neptune Analytics and other options.
  • Choose a vector store for a workload.

Amazon OpenSearch Service and OpenSearch Serverless

Amazon OpenSearch Service stores vectors in knn_vector fields and searches them with approximate k-nearest neighbour algorithms such as HNSW, alongside full-text search, filters and aggregations. This makes it the natural choice for hybrid search and for high query rates with low latency. OpenSearch Serverless offers a vector search collection type that scales capacity automatically, measured in OpenSearch Compute Units (OCUs), without cluster management, and is a default store for Bedrock Knowledge Bases.

The Neural plugin (neural search) lets OpenSearch generate embeddings itself: an ML Commons connector to an Amazon Bedrock embedding model is registered, an ingest pipeline with a text embedding processor embeds documents as they are indexed, and a neural query embeds the query text at search time. Applications then send plain text and OpenSearch handles vectors. Separate indexes or aliases segment content by topic.

True or false

OpenSearch for vectors

Exam skills 1.4.1 · 1.5.3

Check four claims about vector search in OpenSearch.

Log in to try this activity Interactive activities are free with an account.

Amazon Aurora PostgreSQL and Amazon RDS with pgvector

The open-source pgvector extension adds a vector column type, distance operators and HNSW or IVFFlat indexes to PostgreSQL, available on Aurora PostgreSQL and RDS for PostgreSQL. Vectors live next to relational data, so one SQL query can filter by customer, date or permissions, join business tables and order by vector distance, within transactions. It suits teams already running PostgreSQL and workloads where vectors are one attribute of business records. Aurora PostgreSQL is a supported Bedrock Knowledge Bases store, including a quick-create option with Aurora Serverless v2.

CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE product_chunks (id bigserial PRIMARY KEY, product_id int, region text, body text, embedding vector(1024));
CREATE INDEX ON product_chunks USING hnsw (embedding vector_cosine_ops);
-- nearest chunks for one product family in one region (<=> is cosine distance)
SELECT body FROM product_chunks WHERE region = 'EU' AND product_id IN (12, 15)
ORDER BY embedding <=> :query_vector LIMIT 5;

Amazon S3 Vectors, Neptune Analytics and other patterns

Amazon S3 Vectors stores vectors in vector buckets and vector indexes with durable, low-cost storage and sub-second queries, scaling to billions of vectors per index without provisioning. It suits very large or infrequently queried collections, such as archives and agent memory, where storage cost dominates. It can be a Bedrock knowledge base store, and hot subsets can be exported to OpenSearch for high query rates.

Amazon Neptune Analytics combines a graph with vector search and underpins GraphRAG in Bedrock Knowledge Bases, which extracts entities and relationships during ingestion and follows them at query time, improving answers that span connected facts. Other patterns keep original documents in S3 with records in RDS, or item metadata in DynamoDB keyed by document ID while vectors live in a vector store; the search returns IDs, and the application fetches metadata from DynamoDB with single-digit millisecond latency.

Choosing a vector store

Several AWS services can store and search vectors, and the right choice depends on the workload rather than on vector search alone. The main factors are the query rate and latency required, the number of vectors and the budget, the query features needed, such as hybrid keyword and vector search, metadata filters, joins with relational data or graph traversal, and the team's existing skills and tolerance for operational work.

For example, Amazon OpenSearch Service suits high query rates and hybrid search; Amazon Aurora PostgreSQL with pgvector suits applications that already use PostgreSQL and need vectors alongside relational data; Amazon S3 Vectors suits very large collections that are queried less often, at the lowest storage cost; and Amazon Neptune Analytics suits graph-based retrieval. Bedrock Knowledge Bases sit above these stores, managing ingestion and retrieval, and can create some of them automatically. The following table summarises the choice.

StoreStrengthsChoose when
OpenSearch Service / ServerlessHybrid search, high QPS, rich filters, Neural pluginSearch-heavy RAG, exact terms plus meaning
Aurora PostgreSQL / RDS with pgvectorSQL joins, transactions, existing PostgreSQLVectors as part of relational records
Amazon S3 VectorsLowest cost at very large scale, no serversBillions of vectors, modest query rates
Neptune AnalyticsGraph plus vectors (GraphRAG)Answers depend on relationships between entities
DynamoDB with a vector storeFast metadata lookups by IDRich item metadata alongside vector search

The following diagram matches workload needs to vector stores.

Choosing a vector store by workload. OpenSearch suits high query rates and hybrid search; Aurora PostgreSQL with pgvector suits vectors beside relational data; Amazon S3 Vectors suits very large, infrequently queried collections where storage cost dominates; Neptune Analytics suits questions that span related entities through GraphRAG.
Team skills and existing databases also shape the choice.
Sort into groups

Pick the vector store

Exam skills 1.4.1 · 1.5.3

Choose the vector store that fits each workload best.

Log in to try this activity Interactive activities are free with an account.
Worked example

Picking the store

An e-commerce company wants RAG over product descriptions where queries often include exact SKUs and model numbers as well as descriptive phrases, at thousands of queries per second.

Exact identifiers favour keyword matching, descriptive phrases favour semantic matching, and the query rate is high. OpenSearch Service with hybrid search fits. S3 Vectors would be cheaper for storage but is not designed for this query rate, and pgvector would require building keyword search separately.

Check yourself

Vectors must be joined with order data in SQL queries. Which vector store fits?

Show answer

Aurora PostgreSQL or RDS for PostgreSQL with the pgvector extension.

Exam Tips

Remember for the exam

  • Hybrid search and high query rates: OpenSearch.
  • Vectors joined with relational data in SQL: Aurora PostgreSQL or RDS with pgvector.
  • Billions of vectors at lowest cost: S3 Vectors.
  • Relationship-heavy questions: GraphRAG with Neptune Analytics.
  • Neural plugin: OpenSearch generates embeddings with a Bedrock connector.