Primary reference: write documents for retrieval
AWS Prescriptive Guidance explains how clear headings, context, defined terms, text alternatives for tables and graphics, and self-contained documents make source material easier for a RAG system to retrieve and interpret.
Read the AWS writing best practices for RAGBuild a governed corpus, not a document pile
Before parsing, assign every source a trust tier, accountable owner, version, permitted audience, retention rule, and retrieval purpose.
Propagate source locator, version, ACL or tenancy, and freshness metadata to each chunk so authorization, citations, and correction remain possible after indexing.
Primary reference: source metadata sidecars for an S3 data source
Amazon Bedrock documents the adjacent fileName.extension.metadata.json convention, typed metadata values, and the includeForEmbedding choice. Verify store and feature constraints for the actual knowledge base before relying on a filter operator.
Read the Amazon Bedrock S3 source metadata documentationAttach a chunk metadata sidecar, then add unique chunk facts deliberately
For an S3 data source, place a source-metadata sidecar named POL-17-v4.pdf.metadata.json beside policies/POL-17-v4.pdf. Its values are document metadata: Amazon Bedrock applies them to every chunk produced from that document. This is useful for shared provenance and retrieval filters, but it is not yet a distinct per-chunk schema.
S3 source metadata sidecar: POL-17-v4.pdf.metadata.json
A documented typed metadata envelope. The field names below are workload choices; the value envelope and includeForEmbedding flag follow the Amazon Bedrock S3 data-source contract.
Click on an annotation to highlight it in the JSON
includeForEmbedding: false keeps a field available for metadata filtering without adding it to the embedding input. When true, Amazon Bedrock concatenates that key and value into the embedding input; it does not return the metadata as raw chunk text. Treat title inclusion as a measurable relevance hypothesis, not an automatic improvement.
If each passage needs its own chunk_id, section_heading, or page span, use native chunking with a POST_CHUNKING custom-transformation Lambda. That boundary can write unique metadata for each generated chunk; when a chunk-level key collides with file-level metadata, the chunk value wins. Preserve source_id and source_version so every override remains traceable to the document that supplied it.
Document sidecar versus unique chunk metadata
Loading diagram...
Choose parsing and chunking for the retrieval task
Retain headings, tables, page or section boundaries, and source locations before chunking. Fixed chunks are a baseline; semantic chunks use a foundation model to identify meaning-aware breaks; hierarchical chunks pair precise children with broader parents; multimodal content follows model-level or parser-specific handling.
Corpus ingestion decision path
Loading diagram...
Select a parser from the source evidence you need to retrieve
For a customer-managed Knowledge Bases data source, start with the information that must survive ingestion, not with a parser preference. The default parser extracts text only and has no parser usage charge. Choose it when text is the evidence boundary and use representative files to prove headings, locators, metadata, and retrieval are sufficient.
Customer-managed Knowledge Bases parser choices: select, then verify against representative source files
| Choice | Choose when | Configuration and cost boundary | Acceptance evidence |
|---|---|---|---|
| Default parser | Text-only files and text is sufficient retrieval evidence. | Omit parsing configuration; text only; no parser usage charge. | Sampled headings, citations, ACL metadata, and expected passages retrieve correctly. |
| Amazon Bedrock Data Automation (BDA) | PDF figures, charts, tables, or images must become retrievable text without a custom extraction prompt. | KB parser integration is preview and Region-specific as verified on 2026-08-26; page-based charging applies. Standalone BDA availability is a separate product question. | Compare extracted table or figure meaning and source attribution with the original file. |
| Foundation model as parser | Multimodal extraction needs a custom parsing prompt and a supported vision-capable model. | Input and output token charging applies; prompt and model are a versioned ingestion decision. | Golden files show the custom prompt preserves required fields without invented content. |
Parser and representation choice
Loading diagram...
Parser strategy type cannot be changed in place after the data source is connected: moving between BDA, a foundation-model parser, and the default strategy requires a new data source. Within the same parser strategy, AWS documents updating parameters such as a model ARN or parsing prompt by retrieving and resubmitting the complete configuration. Managed Knowledge Bases are a separate, more-opinionated path and currently use SMART_PARSING; do not infer that their configuration or availability matches a customer-managed data source.
Choose chunking against corpus shape and query behavior
Chunking is an ingestion commitment: it fixes what retrieval can see before query-time ranking or prompting begins. Inventory prose, nested policies, tables, code, atomic records, and multimodal media alongside the questions users actually ask. The Agentic AI Lens explicitly warns against a single fixed chunk size for every document type.
Workload-led chunking selection matrix
| Strategy | Choose for | Validate with | Limit to make explicit |
|---|---|---|---|
| Default | A text baseline when no workload evidence justifies tuning. | Representative questions, locators, and context sufficiency. | Approximately 300 tokens with sentence boundaries is a baseline, not a universal answer. |
| Fixed size | Stable prose with a known context-window and overlap trade-off. | Recall, duplication, and passages that cross a topic change. | Token and overlap choices can split tables, code, or related clauses. |
| No chunking / pre-split atomic records | Small self-contained records that you intentionally pre-split into files. | Record-level retrieval, citation, and metadata filtering. | Each document is one chunk; page-number citation metadata is unavailable. |
| Semantic | Flowing prose where topic shifts matter more than a fixed boundary. | Expert review of boundaries plus labelled retrieval cases. | Uses a foundation model and adds cost; buffers and thresholds alter granularity. |
| Hierarchical | Nested documents where precise children need broader parent context. | Child precision, returned parent context, result count, and citation resolution. | Returned results can be fewer than requested; avoid incompatible S3 vector-bucket metadata sizes. |
| Custom transformation | A deterministic domain boundary or chunk metadata cannot be expressed by native choices. | Transformation input/output, lineage, retry, and retrieval regression tests. | The Lambda and intermediate storage become an operated data-processing boundary. |
| Multimodal path | Audio, video, or images need either BDA text conversion or native multimodal embeddings. | Media-specific queries and source-attribution behavior. | Native Nova multimodal embeddings chunk media at the embedding layer; BDA converts to text before text chunking. |
Chunking chooser by source and query shape
Loading diagram...
Treat native Nova multimodal embedding as a representation decision, not as a fourth parser. For audio, video, and images, its media chunking occurs at the embedding-model layer, while BDA converts media to text and then applies text chunking. The connected advanced-retrieval module goes deeper on native multimodal retrieval; here, choose the path that preserves the evidence your workload must retrieve and evaluate it on media-specific cases.
Test hierarchy against the selected vector store
Inspect result count, parent context, metadata size, and citation resolution for the corpus and store you will actually operate.
Operate ingestion as a reversible lifecycle
- Detect source, ACL, parser-version, update, and deletion changes.
- Use source and chunk versions so indexing is idempotent.
- Propagate deletion and permission changes before retrieval.
- Quarantine malformed, unsupported, and ambiguously owned documents.
- Measure sync lag, stale-result rate, and failure reason.
Create an acceptance manifest before a source can be retrieved
A source inventory is not enough. An acceptance manifest makes the ingestible unit explicit: what entered, who approved it, which audience may retrieve it, what parser and chunking policy applied, and how the team will prove that a later update or deletion took effect.
Corpus acceptance manifest
Application-owned control record. Keep source identifiers and governance data outside generated answer text.
Click on an annotation to highlight it in the JSON
Reject a manifest with an unknown owner, ambiguous permitted use, or no update and deletion test. The Generative AI Lens frames data architecture around governed data use; the security reference architecture adds the principle that access to data and systems should be controlled rather than assumed from a model or vector-store choice. Those are architecture controls, not metadata decoration.
Promote source changes with a freshness SLO and retrieval proof
Define a workload-specific freshness SLO before choosing a refresh mechanism: for example, the maximum permitted time from an approved source or ACL change to verified retrieval behavior. Record the source version, parser and chunking profile, expected retrieval outcome, and rollback owner. An ingestion request or a changed object timestamp is not proof that the RAG corpus meets that SLO.
Refresh mechanisms have different source-of-record and promotion boundaries
| Mechanism | Choose when | Promotion evidence | Boundary |
|---|---|---|---|
| Data-source sync | The connected repository remains the source of record and incremental reconciliation is acceptable. | Completed job, per-document logs, expected retrieval, negative ACL check, and deleted-locator absence. | Content changes are reprocessed; eligible metadata-only sidecar changes can update metadata without regenerating embeddings. |
| Direct document ingestion | An S3 or custom data source needs an immediate add, update, or delete through KnowledgeBaseDocuments operations. | Direct operation result plus the same content and authorization checks. | For S3, reconcile the identical change to S3 before the next sync; do not run direct ingestion and StartIngestionJob concurrently. |
| Event-driven sync orchestration | Source events must trigger a controlled sync workflow with deduplication, SLO monitoring, and release gates. | Event-to-job correlation, final job and resource status, retrieval suite, and alert on SLO breach. | The AWS sample is deployable orchestration, not a built-in automatic-sync product feature. |
Refresh promotion lifecycle
Loading diagram...
Enable and retain ingestion evidence at the right operational boundary. Knowledge Bases APPLICATION_LOGS can report a job status and resource-level status reasons plus chunk create, update, delete, and failure statistics. Join that evidence to the source event and retrieval checks: a parser fallback, a failed document, or a deleted source is an investigation signal even when the overall job completes.
Quarantine failures without hiding them
Ingestion quarantine decisions
| Signal | Immediate control | Release evidence |
|---|---|---|
| Unknown owner or audience | Keep source out of the data source scope. | Manifest is rejected with a human owner decision. |
| Parser extracts no usable structure | Quarantine the version and retain the failure reason. | Corrected source passes a representative retrieval check. |
| Permission metadata is missing | Block publication to the retrievable corpus. | Denied-principal retrieval returns no protected chunk. |
| Sync is incomplete or failed | Keep the prior accepted version or surface stale status. | Sync job status and sampled retrieval results are recorded. |
Quarantine is not a silent retry queue. It protects users from a corpus that is half parsed, incorrectly classified, or missing access controls, while giving the data owner a precise repair task. Separate a transient connector failure from a content failure: the former may be retried under an idempotent job policy; the latter needs a changed source, parser, or approval decision before re-ingestion.
Lab: verify sync, replacement, and deletion with retrieval evidence
Build a small controlled corpus with one approved document, one intentionally denied document, and one document that will be replaced. The lab proves lifecycle behaviour by querying the corpus, not by trusting upload timestamps or a successful job submission.
- Record the manifest, source locator, version, expected query, and expected access result for each document.
- Start the documented data-source sync and capture its final status plus any failure reasons.
- Use a retrieval-only query to confirm the approved locator and metadata are present and the denied material is not exposed.
- Replace the approved document, sync again, and verify that a query returns the new version rather than a mixture of old and new passages.
- Delete the source through the documented lifecycle, then verify with a targeted retrieval query that the removed locator no longer appears; escalate if stale evidence remains.
Keep the evidence set small enough for a reviewer to inspect every result. If a deletion cannot be verified at retrieval time, treat the corpus as not ready for that source class and investigate the data-source lifecycle, metadata filters, and application caching boundaries before widening use.
Carry source lineage through every change event
A retrievable chunk is only useful for investigation if the team can trace it back to the source version, owner, parser, access classification, and lifecycle event that created it. Treat source lineage as a change envelope that travels beside ingestion work, not as a note in a release ticket.
Source lineage change envelope
Application-owned event payload. The fields model the evidence needed to diagnose an unexpected retrieval result without embedding sensitive source content in telemetry.
Click on an annotation to highlight it in the JSON
AWS documents custom data sources as a path that can directly ingest or delete documents, while other data-source changes require a sync. It also documents metadata as a retrieval input. Do not generalize one lifecycle to every connector: record the selected source type and use the documented operation for that type. If the event cannot name the expected metadata and verification queries, keep it out of automated publication.
Lineage also prevents a misleading repair: re-running ingestion against the same source version and parser does not fix a bad semantic extraction. Require the event owner to identify what changed in the source, parser profile, metadata contract, or access decision before another attempt is eligible. That record distinguishes an idempotent retry from a new corpus candidate and preserves a defensible audit trail when a user reports stale evidence.
Run semantic and ACL regression tests together
Corpus regression harness
| Case | Change under test | Expected retrieval result | Rollback trigger |
|---|---|---|---|
| Meaning-preserving update | Parser or chunking profile | Named relevant locator remains retrievable. | Relevant evidence disappears or is materially truncated. |
| ACL narrowing | Audience metadata | Authorized result remains; denied principal receives none. | Any denied chunk is returned. |
| Metadata schema change | Filterable source attributes | Known filter returns the intended source version. | Filter errors or silently broadens results. |
| Deletion event | Source removal | Removed locator no longer appears after documented lifecycle completes. | Stale result remains without an explicit bounded cache explanation. |
Run semantic and ACL checks in the same release harness. A parser change can preserve text relevance while dropping metadata; an ACL change can preserve metadata while unexpectedly changing chunk selection. AWS’s metadata guidance shows that metadata fields influence how a knowledge base can query data, while the security reference architecture treats controlled data access as a core architecture concern. The only useful regression result is therefore one that checks both evidence relevance and permitted visibility.
Include a deliberately ambiguous document in the harness, such as a source with a similar title but a different audience. This detects an overly broad semantic match that looks relevant but should never become visible to the test principal. If the candidate returns it, preserve the failing source identifiers, quarantine the change, and correct the metadata or retrieval policy before retrying. Do not hide the case by removing it from the corpus sample.
- Version a small golden corpus with expected source locators and authorized principal classes.
- Run the cases before and after each parser, chunking, metadata, or connector change.
- Diff the source identifiers and access outcomes, not only free-text answer quality.
- Quarantine the candidate corpus and restore the prior accepted source/index version when a rollback trigger occurs.
Glossary: terms first introduced here
These are the technical terms introduced in this step. Later modules build on them rather than redefining them from scratch.
New vocabulary for this step
| Term | Plain-language meaning | Why it matters here |
|---|---|---|
| Chunk metadata sidecar | An adjacent source-metadata file that supplies typed document metadata to the chunks produced from one source object during ingestion. | It makes shared provenance and filter fields inspectable, while showing when a custom transformation is needed for facts unique to each chunk. |
| Parsing strategy | The configured method that extracts usable retrieval content from a source before it is chunked and embedded. | It determines whether text, tables, figures, and other source evidence can survive into the retrieval representation. |
| Parser fallback | The documented use of the default text parser for an individual file when an advanced Knowledge Bases parser cannot parse it. | A completed ingestion job can still lose required multimodal evidence, so teams need file-level and content-level acceptance checks. |
| Chunking | Splitting a source into retrievable passages while retaining a link to the original document and location. | Chunk boundaries affect what can be found, cited, and interpreted together. |
| Source lineage | The recorded path from an indexed passage or derived artifact back to its original source, version, and location. | Lineage supports review, deletion, correction, and an honest citation. |
| Quarantine | A holding state for material that has not passed parsing, safety, permission, or quality checks. | It prevents an unreviewed document from becoming model context just because it arrived in storage. |
| Freshness SLO | A workload-defined target for the maximum time from an approved source or access change to verified retrieval behavior. | It turns a vague request for up-to-date answers into a measurable promotion, alerting, and rollback obligation. |
Knowledge Check
Test your understanding with this quiz. You need to answer all questions correctly to mark this section as complete.