In this article
A structured export preserves citation provenance only when indexed fragments still resolve to the correct source revision and document objects.
Markdown and structured JSON serve different roles in a document-to-RAG pipeline: readable text is useful for retrieval, while structured provenance is needed to reconstruct evidence. Keeping both avoids asking a flattened text export to preserve every table relationship, page location and document hierarchy.
Decide what must be recoverable
The DoclingDocument model represents hierarchy and provenance beyond plain text. Define which relationships the application needs to reconstruct: section membership, table cells, page identity or figure references. A readable Markdown export can preserve some relationships but does not automatically carry the complete structured object. Treat the export as a view over the conversion result rather than the only surviving source artifact.
Compare serialization responsibilities
The official serialization documentation describes choices for exporting document content. A Markdown passage can be convenient for an encoder, while JSON can retain structured fields needed for citation or reprocessing. Neither format proves extraction correctness. If the converter assigns a caption to the wrong figure, serializing that relationship faithfully merely preserves the same error in a more inspectable form.
Build an evidence bundle
Take a report containing a heading, a table and a figure caption. Save the original file, structured conversion and the text actually indexed. Give each indexed fragment a stable reference to the structured object and source revision. Then ask a question whose answer depends on a table row and its caption. Check whether the evidence bundle can reconstruct both without relying on a manually remembered filename.
| Artifact | Primary responsibility |
|---|---|
| Original document | Authoritative source representation |
| Structured JSON | Recoverable hierarchy and provenance |
| Markdown view | Readable content for indexing or review |
| Indexed fragment | Exact text presented to retrieval |
Keep transformations explicit
The Docling implementation supplies conversion and export interfaces. Record transformations between these stages: removal of furniture, addition of headings, table serialization and chunk construction. An indexed paragraph may differ from the source because context was intentionally added. Preserve that distinction so a citation does not pretend the enriched fragment appeared verbatim on a page. Reprocessing should follow the stored conversion contract rather than guessing how the old index was produced.
Test reconstruction, not file existence
Select retrieved fragments and resolve them back to document revision, structured item and original page. Verify that the associated evidence actually supports the answer, including units and qualifications. A JSON file existing beside Markdown is insufficient if identifiers no longer connect them. The acceptance artifact is a traceable example from question to indexed text to source location. This supports reliable correction and reindexing without treating any export format as inherently complete or error-free.
Related reading: A local RAG server: placing components around the GPU; A GPU OCR pipeline for a 1,000-page PDF workload.