Exam Room · Advanced Generative AI Developer

Pop Quiz: Freshness and Access Are Metadata

· 5 min read

Exam-style

One Amazon Bedrock knowledge base serves both HR and Finance. Each team must only ever see its own documents, and superseded policy versions must never be cited even though they stay in the corpus for the record. Which approach enforces both at the lowest ongoing cost?

Reveal the answer

A. Attach department and effective-date metadata to each document and apply a metadata filter on every retrieval request

Department and effective date are attributes of the document rather than parts of its meaning, so a retrieval filter enforces them directly: equals on department, greaterThan on a numeric effective date, joined with andAll. The filter is a separate field from the search type and the reranker, so all three apply to one request. A knowledge base per department doubles the ingestion cost and leaves two corpora to keep in step. Prepending the department to the chunk text is what includeForEmbedding: true already does, and it shifts similarity scores rather than excluding anything. A reranker reorders chunks that retrieval has already returned, so the restricted document reached the candidate set before the rerank ran. Guardrail denied topics are evaluated against prompts and responses; the identity of the caller is not an input to them. One caveat on the filter: anyone holding bedrock:Retrieve on the knowledge base can query it unfiltered, so the application has to build the filter, not the caller.

Generative AI Development · part of The Exam Room

Q. Retrieval must respect access control and document freshness. What enforces both without a second index?

A. Metadata filtering. Attach attributes to each document, then pass a filter inside the vectorSearchConfiguration of every Retrieve or RetrieveAndGenerate call. For an S3 source the attributes go in a filename.pdf.metadata.json file beside the document, under 10 KB, typed STRING, NUMBER or BOOLEAN. andAll joins up to five conditions, so a department test and an effective-date test travel in one request. The greater-than and less-than operators take numbers only, so store dates as numbers such as 20250101. The filter sits alongside overrideSearchType and rerankingConfiguration in the same configuration, so hybrid search and a reranker still apply.

Why? Freshness and access scope are attributes of a document. Filters read attributes; embeddings encode meaning.

These posts are LLM-aided. Backbone, original writing, and structure by Craig. Research and editing by Craig + LLM. Proof-reading by Craig.