Document Ingestion Pipeline
In this article
- Trace one file from its source system through fetch, format detection, parsing, normalization and validation to a canonical document, and name the artifact each stage hands on.
- Read a canonical document and its content blocks, and say which field holds the citation id, the source object id, the version and the permissions.
- Decide when a file must be quarantined, and why a partly extracted file is the failure to catch.
- Tell ingestion apart from chunking, indexing and retrieval.
- Terms defined here: ingestion pipeline, canonical document, content block, metadata, quarantine.
Overview
A search can only find what was put into it. Before a support assistant can answer from a staff handbook, someone has to get the handbook out of the drive where it lives, read a Word file, and turn it into something a search can take in. That work is easy to get quietly wrong: a parser that stops at page 61 of a 120-page file can still report success.
In an invented example, Brightline, a home-internet provider, runs a support assistant on its website that answers customers and can look up an order, issue a refund of at most $50 and hand a conversation to a person on the support team.
Follow one chapter of one Brightline file through that work. There are five stages; each hands on one artifact, each artifact must pass a check, and a file that fails is set aside.
Where ingestion starts and stops
In The RAG Pipeline, the offline lane began with "collect and convert", then "chunk and add metadata", then "index". Ingestion is that first stage: it reads documents from the systems where they are kept and turns each into one structured record, at index time, before any question arrives. It ends where "chunk and add metadata" begins. Cutting documents into chunks, computing embeddings, building the search index and retrieval at question time all come later and are not ingestion.
An ingestion pipeline is the fixed series of steps that does this work, file by file, for every format it meets.
Real content lives in many places and many formats: PDFs, HTML, DOCX, Markdown and more, often spread across document sites, databases and file storage [1,5]. Brightline decides once which of its sources to ingest:
| Source | Where it is kept | Format | Version signal | Ingested? |
|---|---|---|---|---|
| Help pages, about 400 | website content system | HTML | page version number | yes |
| Router manuals, 12 | file store | PDF (11 digital, 1 scan) | file version id | yes |
| Staff handbook, 120 pages | shared drive, folder handbook/ | DOCX | drive revision id | yes |
| Past conversations, many thousands | chat records | records | record updated time | yes |
| Outage notices | outage system | notices | hourly | no, read live |
| Order records | order system | records | per order | no, read through lookup_order |
From here, "the corpus" means the four ingested sources. Outage notices change hourly, so they are read live rather than stored.
Five stages, five artifacts
The running input is the "Fee waivers" chapter of the staff handbook. Follow it left to right; the canonical document at the end is the record described below.
Fetch. A connector, the code that reads one source system and lists its files, takes staff-handbook.docx from the drive. With the bytes it hands on a source descriptor: the system (the shared drive), the location (handbook/staff-handbook.docx), the source object id (the id the drive itself gives the file), the version (the drive revision id) and the permissions as the drive states them.
Detect format. Format detection decides which parser reads the file. A parser is the code that reads one format. A converter such as Docling reads PDF, DOCX, HTML, images and many other formats [2]. The handbook is DOCX, so the decision is "DOCX parser".
Parse. The parser turns the file's bytes into blocks, the pieces of the document such as a heading or a paragraph, in reading order. For the chapter it returns two: the heading "Fee waivers" and one of its paragraphs.
Normalize. Normalization gives every format the same block schema and the same document fields, so the HTML help pages, the PDF manuals and the DOCX handbook all leave in one shape.
Validate. The last stage checks the result before anything is handed on.
Each artifact can be printed and read, so a stage you suspect is easy to test:
| Stage | Artifact it hands on | Check before the next stage takes it |
|---|---|---|
| Fetch | file bytes and source descriptor | file read in full; descriptor has location, object id, version, permissions |
| Detect format | format decision | a parser exists for this format |
| Parse | blocks in reading order | the file opened; blocks are not empty |
| Normalize | blocks in the shared schema, with document fields | every block has every field |
| Validate | canonical document, or a quarantine record | no page or block missing content |
A page with no text layer (no stored characters, only an image), such as the scanned manual manual-bl-r3, is sent by format detection to a different parser, one that reads text from page images (OCR).
Reading text from page images is the subject of OCR, Layout and Vision Parsing.
The canonical document
What validation hands on is a canonical document: one record per source document, with the same shape whatever format the file was. Docling's DoclingDocument follows the same idea: one type for every format, holding headings, paragraphs, tables and pictures in reading order. [3]
Brightline's has six fields. Here is the handbook's, with only the two "Fee waivers" blocks shown and the values made up for the example:
{
"doc_id": "handbook",
"source": {"system": "shared drive", "path": "handbook/staff-handbook.docx", "object_id": "drv-4471"},
"version": "drive revision 57",
"blocks": [
{"source_id": "handbook", "order": 312, "type": "heading", "text": "Fee waivers", "links": [], "page": 47},
{"source_id": "handbook", "order": 313, "type": "paragraph", "text": "A late-payment fee can be waived once in 12 months for a customer with no earlier late payment.", "links": [], "page": 47}
],
"permissions": [{"allow": "support-staff", "on": "document", "noted": "inherited from folder handbook/"}, {"deny": "contractors", "on": "chapter Fee waivers"}],
"quality": {"parser": "docx-parser", "parser_version": "2.3", "pages": 120, "pages_with_blocks": 120}
}doc_id: the course's own id for this document.source: where the file lives, including the source object iddrv-4471that the drive gave it.version: which version of the file this record was built from.blocks: the content, as an ordered list.permissions: who may read it, as the source states it.quality: how it was read, starting with the parser and its version that produced the blocks.
Each entry in blocks is a content block: one piece of the document's structure, such as a heading, a paragraph, a list item or a table. Its fields: source_id names the canonical document it belongs to; order is its place in reading order; type says which kind of piece it is; text is its content; links holds the links it contains; page is where it sits in the file. A block is not a chunk. Chunks are cut later, from blocks, by "chunk and add metadata".
One rule needs care. A block's source_id holds the doc_id of its canonical document, handbook, which is the id a citation shows. It never holds the source object id drv-4471. That id belongs to the drive, and it stays in the document's source field. Mix the two and a citation points at a storage key.
Four of the six fields are document metadata: fields that describe the document rather than hold its content, here source, version, permissions and quality. Who sets each one, and what to do with sensitive values, is the subject of Metadata and Provenance During Ingestion.
Together these fields carry provenance. Every block keeps its source_id, order and page, and the document keeps its version, so any later stage can say that a sentence came from page 47 of drive revision 57 of the handbook.
Permissions are read from the source and stored exactly as the source states them. The handbook allows group support-staff, a grant the drive reports as inherited from the folder, and the "Fee waivers" chapter denies group contractors. Both go into the record unchanged, as an ACL would list them. If different users may see different content, those access rules must survive into the stored pieces [1]. Ingestion records them; retrieval enforces them, filtering by permission at query time [5]. How to turn the drive's groups into one form, and what to do with access rights you cannot read, is the subject of Preserving Source Permissions During Ingestion.
Running ingestion again on the same file version must give the same canonical document, not a second copy. LlamaIndex's ingestion pipeline, for example, with a document store and a vector store attached, skips a document whose id it has already seen with unchanged content [4]. How to detect a change is the subject of Incremental Sync and Change Detection.
When a check fails
Suppose the DOCX parser hits something it cannot read on page 62 and stops, returning blocks for pages 1 to 61 without an error. Predict before reading on: what reaches the index if no stage checks pages?
The index gets a handbook that ends at page 61. By the made-up example's numbers, that is 59 of 120 pages gone, about 29,500 of its roughly 60,000 tokens. The run log says "success", and the record looks normal.
This is why validation compares what came out with what went in. Here pages_with_blocks is 61 and pages is 120, so the check fails. A file that fails a check (a corrupt file, a format with no parser, or a parse with content missing) goes to quarantine: it is set aside with the reason recorded and reported, and it is never handed on or indexed with partial or guessed content. The handbook stays out until the parser is fixed and the file passes, and its quarantine record reads "pages 62 to 120 have no blocks".
Validation also looks inside the blocks: a block of type table with empty text, or a page with no text where the file has some, fails the file in the same way.
Scans are a known trap. A scanned image may not let you extract usable text at all [1]. If format detection looks only at the file type (PDF) and misses the absent text layer, manual-bl-r3 goes to the text parser, opens without error and yields empty blocks. Validation is the safety net. Without a check, an empty manual counts as a success; with one, it is quarantined.
Why not index what you have? A missing manual is a known gap the team sees in the quarantine report; a half manual gives wrong answers nobody traces back.
Common mistakes
- Counting a file as a success when part of it was not extracted. Count pages or sections in and out.
- Writing the source object id into
source_id. Citations then show a storage key, not a document. - Treating every framework's "ingestion pipeline" as this one. LlamaIndex's version can also split text and compute embeddings in the same run [4]; in this course those steps come after ingestion.
The following articles open these stages one at a time.
Reading HTML, DOCX and digital PDF files is the subject of Parsing Digital Documents.
Sources
- RAG solution on Azure: preparation phase. Microsoft. Checked 21 Nov 2026.
- Docling. Docling project (docling-project GitHub organization). Checked 24 Oct 2026.
- Docling docs: DoclingDocument concept. Docling project. Checked 24 Oct 2026.
- Ingestion Pipeline (LlamaIndex docs). LlamaIndex. Checked 25 Oct 2026.
- Microsoft Learn: Retrieval-augmented generation in Azure AI Search. Microsoft. Checked 24 Oct 2026.
- Filter by metadata (Pinecone docs). Pinecone. Checked 21 Nov 2026.
Check yourself
Check yourself
Question 1 of 13
Which task belongs to ingestion rather than to a later stage?
Your first check counts towards your result.