Enrichment Chunking Indexing Layer
Categories:
Purpose
The enrichment, chunking, and indexing layer is the downstream preparation layer that turns validated canonical documents into retrievable knowledge units.
Its job is to:
- add retrieval-useful annotations without changing source truth
- define the retrieval units that search and reranking can operate on
- build the access paths that allow the retriever to reach the right evidence
- preserve traceability, trust signals, and structural relationships through indexing
This layer begins only after ingestion and validation have produced trusted canonical documents.
The key idea is simple:
Retrieval quality depends not only on good search algorithms, but on how documents are enriched, split, represented, and indexed before retrieval starts.
Scope
This document covers:
Validated canonical document
-> Enrich
-> Chunk
-> Index
-> Publish to retrieval
This document does not cover:
| Out of scope | Why |
|---|---|
| source acquisition | belongs to ingestion |
| OCR and parsing | belongs to ingestion |
| structure reconstruction | belongs to ingestion |
| validation and quarantine | belongs to ingestion validation |
| retrieval query shaping | belongs to retrieval |
| ranking and answer generation | belongs to downstream RAG execution |
Relationship to Other Layers
The upstream dependency is CH03_01_Ingestion-Validation-Layer.md.
That layer produces validated canonical documents with:
- source lineage
- normalized structure
- trust signals
- validation status
- repair history when applicable
This layer assumes those inputs are already present.
The downstream dependency is CH03_RAG-Layer.md, where these outputs are used by retrieval.
Design Goals
- preserve document meaning while making content retrievable
- separate source truth from inferred retrieval annotations
- support both exact lookup and semantic retrieval
- preserve section, parent-child, and source-span traceability
- handle tables and structured blocks as first-class content types
- support bilingual or parallel-document alignment where available
- publish only index states that are consistent and versioned
Core Principles
1. Enrichment Should Annotate, Not Rewrite
Enrichment should add useful retrieval signals.
It should not silently replace source truth or hide ambiguity.
2. Chunking Defines What Retrieval Can Know
The retriever can only return the units it is given.
If chunk boundaries destroy structure, later retrieval quality will suffer no matter how strong the retriever is.
3. Tables and Structured Blocks Need Specialized Handling
Flattening all content into prose is usually lossy.
Tables, lists, forms, and policy clauses often require chunk rules and index fields that differ from plain paragraphs.
4. Indexing Is Not Just Embedding Storage
Indexing is the design of retrieval access paths.
It determines whether the system can perform exact match, semantic match, filtering, parent expansion, and traceable retrieval.
5. Publish Only Coherent Retrieval States
Retrieval should not see half-built or partially inconsistent index states.
Use versioned publish boundaries.
Module Boundaries
| Step | Responsibility | Outputs | Important rules |
|---|---|---|---|
| Enrich | attach retrieval-useful annotations such as section metadata, entity tags, summaries, keyword expansions, bilingual links, and trust-aware fields | enriched document object | keep authoritative and inferred fields separate; enrichment must not override source truth |
| Chunk | split enriched documents into retrieval units while preserving structural meaning and traceability | chunk set with parent-child links and source spans | chunk by structure first, not token count alone; do not break atomic structured content carelessly |
| Index | build lexical, vector, metadata, and parent-access paths over chunks | indexable retrieval corpus and index snapshots | index design must preserve traceability, filtering, and parent expansion capability |
| Publish to retrieval | expose only approved index snapshots to the retrieval runtime | published retrieval state | do not expose half-built or unvalidated index states |
Control and Governance in This Layer
This layer does not define access policy, but it must preserve and enforce the metadata needed for safe retrieval later.
| Control concern | How it applies in this layer |
|---|---|
| ACL propagation | carry access labels from canonical documents into enriched documents, chunks, and index records |
| trust propagation | preserve validation status and trust level through chunking and indexing |
| version propagation | keep source version and corpus version tied to chunk and index records |
| publish consistency | expose retrieval only to coherent, versioned index snapshots |
| bilingual alignment safety | preserve paired ids without letting alignment override source truth |
Important principle:
If chunks or indexes lose ACL, trust, or version information, retrieval cannot enforce control correctly.
1. Enrich
Purpose
Enrichment adds retrieval-useful signals to validated canonical documents.
It should improve retrieval, filtering, and ranking without changing the underlying source meaning.
Enrichment Categories
| Enrichment category | Typical fields | Why it matters |
|---|---|---|
| Authoritative metadata | document id, version, effective date, owner, source system, ACL, language | trusted metadata for filtering, governance, and traceability |
| Structural metadata | section path, heading titles, block type, page spans, parent-child relationships | preserves document structure for retrieval and context assembly |
| Retrieval metadata | canonical entities, aliases, keywords, normalized dates, region, audience, product, document type | improves retrieval recall and precision |
| Synthetic retrieval aids | chunk titles, summaries, keyword expansion, table header normalization | helps weak local context become more retrievable |
| Trust and provenance metadata | validation status, trust level, repair history, extractor info | lets downstream systems reason about content quality |
| Bilingual or parallel alignment metadata | paired document id, paired section id, paired table id, cross-language consistency score | supports cross-language retrieval and validation-aware ranking |
Important Design Rule
Keep authoritative and inferred metadata separate.
Recommended pattern:
| Field type | Example |
|---|---|
| authoritative | authoritative.region = APAC |
| inferred | inferred.region = APAC |
| inferred confidence | inferred.region_confidence = 0.82 |
This prevents enrichment from polluting source truth.
The confidence value above is an illustrative example, not a calibrated production value.
Common Enrichment Failures
| Failure | Example impact | Mitigation |
|---|---|---|
| wrong inferred entities | bad filter or wrong retrieval routing | attach confidence and avoid hard filters on weak inferred fields |
| misleading summaries | retrieval is biased toward wrong interpretation | keep summary tied to source spans and validate summary quality on samples |
| alignment attached to wrong section | cross-language logic becomes noisy | use stable section ids and alignment audits |
| enrichment hides ambiguity | later retrieval behaves overconfidently | preserve uncertainty explicitly |
Control Notes for Enrichment
- authoritative and inferred fields should remain separate
- ACL and trust metadata should be preserved as first-class fields
- inferred metadata should not become hard filter truth unless explicitly promoted
2. Chunk
Purpose
Chunking transforms enriched documents into retrieval units.
It determines what search, reranking, and context assembly are able to operate on.
Chunking Principles
| Principle | Meaning |
|---|---|
| structure-aware first | preserve sections, tables, lists, and policy blocks before applying token-based splits |
| parent-child by default | use larger logical parents and smaller retrieval children |
| atomic structured content | keep tables, forms, and rule-exception blocks intact when possible |
| traceability preserved | every chunk must map back to document, page, and span |
| trust preserved | chunk must inherit document trust or block-level trust signals |
Chunk Model
| Chunk layer | Role | Typical use |
|---|---|---|
| Parent chunk | section or logical block | context expansion, parent recovery, document structure |
| Child chunk | retrieval-sized unit | lexical search, vector search, reranking |
This parent-child model gives:
- small units for precision
- larger context when needed
Chunk Types
| Chunk type | Special handling |
|---|---|
| prose chunk | split by section or subsection before token windows |
| table chunk | preserve table structure; optionally create table-level and row-group variants |
| list chunk | keep heading with bullets or numbered items |
| form chunk | preserve field-label and field-value structure |
| note or footnote chunk | retain attachment to parent context |
Chunk Output Contract
| Field | Purpose |
|---|---|
chunk_id | stable retrieval unit id |
doc_id | source document linkage |
version | traceability and freshness |
language | language-aware retrieval |
paired_chunk_id | bilingual or parallel alignment linkage |
chunk_type | retrieval strategy and context assembly hint |
section_path | structural context |
parent_chunk_id or parent_section_id | parent expansion support |
text | primary searchable content |
structured_payload | non-prose structured content such as tables or forms |
page_span | citation and traceability |
source_spans | fine-grained provenance |
trust_level | downstream quality awareness |
Control Notes for Chunking
- chunk must inherit access scope from its source document or source block
- parent-child relationships must not bypass access boundaries during later expansion
- chunk ids and source spans should support later audit and redaction checks
Common Chunking Failures
| Failure | Example impact | Mitigation |
|---|---|---|
| chunk too small | rule loses exception or scope | preserve section logic and expand parent context |
| chunk too large | retrieval precision drops | split oversized sections into child chunks |
| table header separated from values | table becomes semantically unusable | keep structured table chunking |
| bilingual alignment lost | cross-language retrieval degrades | preserve alignment ids through chunk generation |
| low-trust content chunked anyway | bad content leaks into retrieval | only chunk validated content |
3. Index
Purpose
Indexing creates the retrieval access paths over chunks.
It is not only about storing embeddings.
Index Families
| Index family | Purpose | Typical content |
|---|---|---|
| Lexical index | exact names, ids, codes, keywords | titles, ids, section text, table headers, canonical aliases |
| Vector index | semantic similarity and paraphrase match | chunk text, summaries, selected structured text renderings |
| Metadata index | filtering and governance | doc type, region, version, ACL, language, trust level |
| Parent or document lookup | parent expansion and structure recovery | parent-child links, section hierarchy, doc-level metadata |
| Optional entity or graph index | specialized relationship lookup | entity ids, relationships, business graph edges |
Field-Aware Indexing
Not all fields should be indexed the same way.
| Field | Why it matters |
|---|---|
| title or heading | often carries high retrieval value |
| section path | disambiguates local text |
| body text | main semantic content |
| table header | key for structured lookup |
| table cell text | useful for field-level or row-level retrieval |
| aliases and canonical entities | improves exact and fuzzy matching |
| summary | improves retrieval for weak local chunks |
Bilingual Indexing Strategy
For bilingual or parallel corpora, a practical default is:
| Strategy component | Recommendation |
|---|---|
| lexical indexing | keep language-aware lexical indexes or language-specific fields |
| vector indexing | use language-aware or multilingual embeddings depending on corpus behavior |
| metadata | keep shared canonical metadata across language versions |
| alignment | preserve paired document, section, and chunk ids |
This is usually better than collapsing everything into one flat multilingual representation.
Index Publish Model
Retrieval should consume published index snapshots, not live partial writes.
| Publish concern | Recommendation |
|---|---|
| partial rebuild risk | use staging build before publish |
| stale entries | support explicit delete or tombstone propagation |
| version rollback | keep index version history |
| retrieval consistency | publish only coherent snapshots |
Control Notes for Indexing
- metadata indexes must support permission-aware filtering
- lexical and vector records should carry traceable ids back to chunk and document level
- published index snapshots should be auditable and reversible
Common Index Failures
| Failure | Example impact | Mitigation |
|---|---|---|
| vector-only design | exact lookup fails | keep lexical index alongside vector index |
| missing metadata index | filtering becomes weak or slow | maintain explicit metadata access path |
| lost parent links | context expansion fails | preserve parent-child linkage in index records |
| stale entries remain live | old policies outrank current ones | versioned snapshots and tombstones |
| table content flattened badly | structured answers degrade | use structured or field-aware indexing for tables |
4. Publish to Retrieval
Purpose
This step exposes a consistent retrieval-ready state to the online retrieval system.
It should be treated as a release boundary, not a background side effect.
Publish Contract
| Publish artifact | Purpose |
|---|---|
| index snapshot id | stable retrieval state version |
| corpus version | tie retrieval state back to source state |
| chunk count and doc count | sanity checks |
| trust distribution | quality visibility |
| deletion and tombstone summary | freshness and cleanup visibility |
Publish Rules
| Rule | Why it matters |
|---|---|
| publish only coherent snapshots | prevents mixed-state retrieval |
| keep rollback path | recover from bad rebuilds |
| log publish metadata | supports debugging and audits |
| preserve traceability through snapshot ids | supports downstream investigation |
Minimal Serious Baseline
For a practical baseline, this layer should at least provide:
| Capability | Why it matters |
|---|---|
| authoritative vs inferred metadata separation | avoids polluting truth |
| structure-aware parent-child chunking | improves precision and context recovery |
| special table handling | prevents structured data from collapsing into poor prose chunks |
| lexical plus vector indexing | supports both exact and semantic retrieval |
| metadata and ACL-aware indexing | supports filtering and governance |
| stable chunk ids and parent links | supports traceability and context expansion |
| versioned publish snapshots | prevents inconsistent retrieval states |
Implementation Approach for Enrichment and Chunking
Unlike indexing, enrichment and chunking are usually not owned by a single storage platform.
They are typically implemented as pipeline logic over validated canonical documents using a mix of parsers, NLP or LLM services, chunking libraries, and corpus-specific rules.
Practical guidance:
- implement enrichment as document-processing code that adds authoritative metadata, inferred retrieval metadata, summaries, aliases, structural annotations, and trust or provenance fields without altering source truth
- implement chunking as structure-aware pipeline logic that splits by section, table, list, form, or policy block before applying token-sized child chunks
- use existing libraries as building blocks, but treat parent-child chunk design, ACL propagation, traceability, and publish consistency as application responsibilities
Useful tooling categories:
| Need | Typical options | Why they help |
|---|---|---|
| document parsing and structure extraction | Unstructured, Apache Tika, Docling, PyMuPDF, pdfplumber | extracts sections, pages, tables, and layout cues needed before enrichment and chunking |
| metadata and entity enrichment | spaCy, Hugging Face models, domain rules, LLM-based enrichment | adds retrieval-useful metadata, aliases, summaries, and normalized fields |
| baseline chunking utilities | LangChain text splitters, LlamaIndex node parsers, tokenizer-aware splitters | provides starter chunking primitives, especially for simple prose corpora |
| production chunking logic | custom structure-aware chunkers | preserves document-specific semantics such as rule-exception blocks, tables, forms, and bilingual alignment |
Important note:
There are common libraries for enrichment and chunking, but strong production behavior usually comes from combining those building blocks with corpus-specific pipeline rules.
Index Tooling Options
Keep this section short and practical.
These options apply primarily to the indexing and retrieval-storage part of the layer, not to enrichment or chunk generation.
| Use case | Recommended option | Why |
|---|---|---|
| strongest open-source hybrid indexing and ranking platform | Vespa | strong lexical plus vector retrieval, ranking control, production-grade search architecture |
| best practical open-source lexical plus metadata index | Elasticsearch (default), OpenSearch as drop-in alternative | mature filtering, keyword search, and operational ecosystem |
| best practical open-source vector index | Qdrant | strong vector retrieval with metadata filtering and simpler adoption |
| simplest early-stage option if Postgres is already core | pgvector | operationally simple, good enough for smaller or earlier-stage systems |
Practical recommendation:
- use Elasticsearch plus Qdrant as the most practical open-source split stack; OpenSearch is a drop-in substitute if licensing or ops constraints prefer it
- use Vespa when you want stronger unified hybrid retrieval and ranking control
- use pgvector only when simplicity matters more than peak retrieval capability
The named default matches the set-wide reference stack in CH03_RAG-Layer.md.
Final Note
This layer should be treated as retrieval preparation, not as a generic text-preprocessing step.
When enrichment, chunking, and indexing are designed well, retrieval becomes simpler, cheaper, and more reliable.
When they are weak, even strong retrieval algorithms will be forced to work on poor representations of the source knowledge.