Skip to main content
Chunking is part of the Ingest workflow. It turns extracted Markdown documents into smaller passages before embedding and storage. Use this page to choose the right chunking shape. Use the interface-specific pages when you need exact parameters, flags, request fields, or response shapes.
Search works best on focused passages, not whole files. Chunking lets a query match the paragraph or table row range that answers it instead of retrieving a 50-page document.

What the chunker preserves

Ragrails chunks Markdown semantically before embedding:

Inputs

The SDK and REST API accept a Markdown string or a list of document dictionaries. The CLI reads JSON document files from an input directory.
SDK and REST document dictionaries must include a non-empty text field. The SDK does not accept markdown or content aliases in document dictionaries.

Configuration

The same three sizing controls exist across SDK, CLI, REST, and the high-level ingest pipeline.
Start with chunk_size=2000, chunk_overlap=200, and min_chunk_length=100. Lower the size for dense factual content such as FAQs, API references, and policies. Raise it for narrative content where surrounding context matters.
Overlap helps when a sentence or thought lands near a boundary. Keep it around 10% of chunk_size unless retrieval quality tests show a reason to change it.

Metadata and output shape

Every chunk includes text for display, enriched text for embedding, and metadata for filtering, citations, and maintenance.
embed_text prepends available title, heading path, and description to the visible chunk text. Use text for citations and UI display; use embed_text when sending chunks to embedding providers.
Chunking does not parse YAML frontmatter. Pass title, description, source_kind, and other metadata explicitly, or preserve them from extraction outputs.

Tables

Markdown tables get table-specific metadata. If a table is larger than chunk_size, Ragrails splits it into row groups and repeats the table header in each chunk.
Use table_id, row_start, and row_end when you need table-aware citations or when you want to merge adjacent retrieved table chunks in an answer layer.

Ingest pipeline

When you call high-level ingestion, chunking is the stage between extraction and embedding. Pass chunking options through the chunking object.

Possible errors

Interface validation errors raise immediately in SDK and REST. Per-document core failures are returned in the result errors list when some inputs can still be processed. See Errors for the shared shapes.

Next steps

  • Use Embedding to turn chunks into vectors.
  • Use Storing to write embedded chunks to a vector database.
  • Use Ingest to run extraction, chunking, embedding, and storage together.