Cloud concept · Updated

Vector Search - Vector search retrieves items by comparing numerical representations called vectors and ranking them by similarity to a query vector.

In short

Embedding models represent text, images, audio, or other data as vectors whose relative positions can reflect meaningful relationships. Vector search uses these representations to find related content even when exact words differ, supporting semantic retrieval, recommendations, and retrieval-augmented generation.

Cloud Concepts Hub →

6 key aspects of Vector Search

Effective vector search combines compatible embeddings, suitable similarity measures, evaluated indexing strategies, authorized retrieval, and disciplined data lifecycle management.

01
Compatible embedding representations

Represent content and queries as vectors in a compatible embedding space. Choose a model appropriate for the data and retrieval task, and track its version, dimensions, and configuration.

02
Similarity measures

Rank candidates using measures such as cosine similarity, dot product, or Euclidean distance. Follow the embedding model's guidance because normalization and metric choice can change the ranking.

03
Exact and approximate retrieval

Exact search preserves the true nearest-neighbor result, whether implemented through exhaustive scanning or an exact index. Approximate indexes can improve latency or resource usage at the cost of potentially missing true neighbors, so measure recall under realistic workloads.

04
Filtering and hybrid retrieval

Combine vector similarity with constraints such as tenant, language, product, and document status. Add lexical retrieval when exact terms matter, and verify that filtering preserves authorization and sufficient result coverage.

05
Foundation-model grounding

Retrieve relevant passages as external context for RAG instead of placing the entire knowledge base into every prompt. This supports grounded answers but does not eliminate generation errors or replace evaluation.

06
Index lifecycle and security

Keep embeddings synchronized with source changes, deletions, and permissions. Plan model migrations and protect vectors, metadata, and retrieved text according to their sensitivity.

Cloud services for Vector Search

An embedding model, such as one available through Amazon Bedrock, converts source content and queries into compatible vectors. OpenSearch Service provides a search-oriented backend, while Aurora PostgreSQL-Compatible Edition and RDS for PostgreSQL support SQL-based vector storage through pgvector. Neptune Analytics supports retrieval involving graph embeddings and relationships. These services are usually alternative retrieval backends, not components every application must deploy together. An application or supported managed RAG workflow retrieves authorized passages from the selected backend and supplies them to a foundation model. Ingestion processes maintain source freshness, embedding consistency, and deletion handling.

Amazon OpenSearch ServiceAmazon OpenSearch Service

Stores and indexes embeddings for vector similarity search and supports combining vector retrieval with lexical search and metadata filters. It is useful when an application needs a search-oriented retrieval layer across multiple content sources.

Amazon AuroraAmazon Aurora

Amazon Aurora PostgreSQL-Compatible Edition supports the pgvector extension for storing and searching embeddings with SQL. Applications can combine vector retrieval with relational records and joins; do not assume the same extension support applies to Aurora MySQL-Compatible Edition.

Amazon NeptuneAmazon Neptune

Within the Neptune family, Amazon Neptune Analytics supports storing embeddings associated with graph vertices and performing vector similarity searches. Applications can combine similarity retrieval with graph relationships; distinguish these capabilities from those of Neptune Database.

Amazon Bedrock

Provides access to embedding models and foundation models used around the retrieval pipeline. Amazon Bedrock Knowledge Bases can orchestrate supported RAG workflows with compatible vector stores, but model invocation itself is not a vector database.

Vector Search exam questions

Real practice exam questions on Vector Search, with the correct answer and its explanation. Answer them with every option in the exam simulator.

AIF-C01

A design agency is building an FM-powered application that finds reference images with visual characteristics similar to an uploaded image. An embedding model already generates vectors for both stored images and uploaded images. Usage varies sharply during client campaigns. The agency needs a managed store that indexes the vectors and performs similarity searches, without requiring the team to select database instance types or manage search-cluster node counts. Which solution best meets these requirements?

Show answerCORRECT ANSWER

Use an Amazon OpenSearch Serverless vector search collection with a vector index for the image embeddings.

An OpenSearch Serverless vector search collection can store and index image embeddings for similarity searches. It manages the underlying capacity without requiring the agency to select database instance types or manage search-cluster node counts.

MLA-C02 (beta)

A company operates a multitenant semantic-search application on Amazon OpenSearch Service. Each indexed passage includes an embedding and a tenantId field. The index uses an approximate k-nearest neighbor (k-NN) engine that supports efficient filtering.

For each user request, the application retrieves the 20 nearest passages across all tenants and then discards passages belonging to other tenants. If fewer than 10 passages remain, the application repeats the search with a larger candidate count. As more tenants join, monitoring shows increasing search calls and CPU consumption per user request, even though request volume is stable. Most discarded results belong to other tenants.

The company must eliminate retries caused by this filtering pattern without increasing the number of globally retrieved candidates. It must preserve semantic retrieval and ensure that only the authenticated tenant's passages are returned.

Which change should an ML engineer make?

Show answerCORRECT ANSWER

Include a tenantId filter inside the k-NN query, using the engine's efficient filtering capability to select neighbors from the authenticated tenant's passages.

Efficient filtering incorporates the tenant restriction into vector retrieval instead of discarding other tenants' results afterward. This addresses the unnecessary search calls caused by post-retrieval filtering while preserving semantic similarity ranking within the eligible tenant's passages.

SAP-C03

A SaaS company operates a retrieval-augmented generation (RAG) assistant for 5,000 tenants. A shared Amazon OpenSearch Service index stores document chunks, embeddings, and a tenant_id keyword field. The vector field uses a Lucene HNSW index. The application derives the tenant ID from the authenticated user's identity.

Currently, the application retrieves the 100 nearest vectors across the index and then removes chunks belonging to other tenants. Small tenants frequently receive no context even when they have many relevant chunks. Some large tenants have millions of chunks.

The company requires tenant restrictions to be enforced within OpenSearch before candidate passages are returned to the application. Retrieval should return up to 20 tenant-authorized nearest neighbors when enough matching documents exist, without retrieving thousands of cross-tenant candidates or exhaustively scoring every document belonging to a tenant.

Which solution best meets these requirements?

Show answerCORRECT ANSWER

Place a term filter for the authenticated tenant_id inside the k-NN query's filter parameter, and request 20 neighbors. Use Lucene's efficient k-NN filtering to incorporate the restriction into vector retrieval.

Lucene supports efficient filtering within an OpenSearch k-NN query. Supplying the tenant restriction inside the k-NN filter allows neighbor selection to account for eligibility instead of discarding other tenants' results after global candidate selection. This addresses underfilled results while avoiding application-side oversampling and an exhaustive script-based similarity calculation over every tenant document. OpenSearch may choose its internal search strategy based on filter selectivity.

Practice Vector Search in a full exam

Questions on Vector Search in each practice exam, with every answer option and an explanation for each:

Start a free practice exam

What is Vector Search

3 min read

Vector search finds items whose numerical representations are close to a query vector under a chosen similarity measure. An embedding is a vector produced by a model to represent characteristics of an input, such as the meaning of a paragraph or the visual features of an image. For example, a search for “recover account access” might retrieve a document titled “Reset your password” even without matching the query's exact wording. Retrieval quality depends on what the embedding model captures; numerical proximity does not prove relevance or factual correctness.

A typical cloud implementation starts with an ingestion pipeline. The pipeline extracts content, divides long documents into useful chunks, generates an embedding for each chunk, and stores each vector with an identifier and metadata. Source text can reside alongside the vector or in another system accessible through the identifier. At query time, the application embeds the query into a compatible vector space and retrieves the closest matching records. Query and document embeddings must use compatible models and configurations; matching vector dimensions alone does not make unrelated embedding spaces comparable.

In retrieval-augmented generation, or RAG, the application supplies retrieved passages to a foundation model as context. For an internal support assistant, vector search can retrieve troubleshooting instructions that the model uses to draft an answer with source references. The vector database stores and searches embeddings; it does not inherently generate embeddings or write answers. Retrieval does not retrain the foundation model, and providing relevant context does not guarantee that the generated answer will be correct.

Several cloud storage patterns support this design. Amazon OpenSearch Service provides vector indexing and search alongside lexical search and metadata filtering. Amazon Aurora PostgreSQL-Compatible Edition and Amazon RDS for PostgreSQL support the pgvector extension, allowing embeddings to reside near relational records and participate in SQL queries. Within the Amazon Neptune family, Neptune Analytics supports vector similarity search over embeddings associated with graph vertices. This enables similarity retrieval to be combined with relationship analysis. Capabilities differ by engine, deployment option, and extension version, so a service-family name alone is not sufficient to establish support.

Search designs balance accuracy, latency, memory, storage, and update cost. Exact nearest-neighbor search returns the true nearest neighbors under the selected metric. Brute-force exact search compares the query against every eligible vector, while some exact indexing methods can prune candidates without sacrificing exactness. Approximate nearest-neighbor indexes reduce search work at scale but may miss some true nearest neighbors. Their usefulness depends on measured recall and latency for the workload. Cosine similarity, dot product, and Euclidean distance are common comparison methods; select the method and normalization that match the embedding model's guidance.

Vector search does not automatically replace keyword search. Product codes, error identifiers, and precise names often benefit from lexical matching. Hybrid retrieval combines lexical and vector results, and a reranking model can reorder retrieved candidates. Evaluate retrieval with representative questions and relevance judgments rather than interpreting similarity scores as probabilities of correctness. Chunk size, metadata filters, candidate counts, and embedding quality all affect results.

Operational controls are essential. Enforce tenant and document permissions before retrieved content reaches the model; semantic similarity is not authorization. Propagate source updates and deletions to the vector store, and track embedding model versions. Changing models generally requires re-embedding the corpus and rebuilding or migrating indexes. Budget for embedding generation, ingestion, index capacity, replication, and queries. Protect embeddings as potentially sensitive derived data rather than assuming they anonymize their source content.

Learn Vector Search in lessons

13 short lessons on Vector Search in 5 certification courses.

and 7 more lessons

Open the lessons