Document and loaders
A LangChain Document holds page_content, a metadata dictionary, and an optional ID. A loader converts a file or external source into these objects.
Tiny example
Section titled “Tiny example”from langchain_core.documents import Document
document = Document( page_content="Refunds are available for 30 days after delivery.", metadata={ "source": "returns-policy.pdf", "page": 4, "tenant_id": "shop-17", "version": "2026-08-01", },)Ingestion checklist
Section titled “Ingestion checklist”- Load bytes from the authorized source.
- Preserve headings, tables, page numbers, and document IDs where possible.
- Attach version, tenant, permission, and provenance metadata.
- Inspect extracted text before chunking.
Failure note
Section titled “Failure note”Retrieval cannot recover text a loader lost. PDFs can scramble columns, omit scanned pages, or flatten tables. Test representative files, record parse failures, and never trust a source filename as an authorization boundary.