AWS Cloud Certify · Practice exams

RAG Retrieval on Amazon Bedrock: Hybrid Search, Reranking and Metadata Filtering

Once documents are indexed, retrieval settings decide what the model sees. This page covers the knobs the exam expects you to know: search type, reranking, metadata filters, query decomposition and the difference between Retrieve and RetrieveAndGenerate.

Key points (7)

Knowledge Bases · Hybrid search

Hybrid search combines vector (semantic) search with raw-text search, which helps with exact terms and acronyms that embeddings blur. Set overrideSearchType to HYBRID; it only works for RDS, OpenSearch Serverless and MongoDB stores with a filterable text field, otherwise the query uses semantic search.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Knowledge Bases · Metadata filtering

Retrieve and RetrieveAndGenerate accept metadata filters (equals, in, greaterThan, and so on) that narrow the search before ranking. Combine them with andAll or orAll, up to 5 per group. For S3 sources, metadata comes from a fileName.extension.metadata.json file next to each document.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Knowledge Bases · Reranking

A reranker model reorders the retrieved results by relevance to the query. Use it when vector search returns passages that are semantically similar but not actually relevant; it is a setting of the knowledge base query, not a new component to build.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Knowledge Bases · Query decomposition

Query decomposition breaks a complex question into sub-queries so a multi-part question retrieves better. In RetrieveAndGenerate set orchestrationConfiguration.queryTransformationConfiguration.type to QUERY_DECOMPOSITION; it may run several queries against the knowledge base.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Knowledge Bases · Retrieve vs RetrieveAndGenerate

Retrieve returns the source chunks; RetrieveAndGenerate also asks a model to write the answer, and RetrieveAndGenerateStream streams it. By default a query returns up to five results; change it with numberOfResults.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Knowledge Bases · Citations need the output format placeholder

In a custom knowledge base prompt template, $search_results$ is required, and removing $output_format_instructions$ means the response will not contain citations. Write your own formatting instructions only if you accept losing citations.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Troubleshooting · Metadata filters need the faiss engine

If metadata filtering fails on an OpenSearch Serverless vector index, check the engine: the index must use faiss, not nmslib. Create a new index with faiss, or let Bedrock create the index for you. On an S3 vector bucket startsWith and stringContains filters are not available.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

Where this fits in the exam

Guides that go deeper

Practice this topic

Answer practice questions, then review your mistakes with spaced repetition.

Start a test

More GenAI Developer study topics