What this thread does
Do first: Import DocumentSplitter from haystack.components.preprocessors, choose split_by and split_length, then call run(documents=...).
Short answer
The current documentation is labeled 3.5. DocumentSplitter accepts a list of Documents and returns split Documents under the documents key. Place it in indexing after conversion/cleaning and before writing or embedding.
What to do
| Value | Action / meaning |
|---|---|
3.5; haystack-ai | Documentation version and package name; no release date is shown. |
from haystack.components.preprocessors import DocumentSplitter | Component import; input and output are lists of Documents. |
split_by="word" | Default unit. Accepted: function, page, passage, period, word, line, sentence, token. |
split_length=200 | Default maximum units per chunk; the unit is chosen by split_by. |
split_overlap=0 | Default units repeated between consecutive chunks. |
split_threshold=0 | Default minimum fragment size; a smaller fragment attaches to the previous split. |
word=" "; period="."; passage="\n\n"; page="\f"; line="\n" | Delimiter definitions; sentence uses NLTK and token uses tiktoken. |
splitting_function=None; split_by="function" | For function mode, provide a callable accepting str and returning list[str]. |
respect_sentence_boundary=False | Set True for word splitting that avoids cutting sentences; uses NLTK. |
language="en" | NLTK language default is English. |
use_split_rules=True; extend_abbreviations=True | Sentence heuristics and curated abbreviations are enabled by default; curated abbreviations support en/de. |
skip_empty_documents=True | Skip empty content by default; False lets later components extract non-textual content. |
split_by="token"; pip install tiktoken | Token mode requires tiktoken. |
tokenizer_encoding="o200k_base" | Default encoding used only for token mode; special-token strings are ordinary counted text. |
warm_up(); run(documents=[doc]); result["documents"] | Warm up tokenizer/encoder, run splitting, and consume returned Documents. |
source_id; page_number | Added metadata tracks the original document and starting page, counted by form feeds. Other metadata is copied. |
TypeError; ValueError | run raises TypeError for a non-list of Documents and ValueError for None content. |
Minimal use with an existing Document named doc:
from haystack.components.preprocessors import DocumentSplitter
splitter = DocumentSplitter(split_by="word", split_length=200, split_overlap=0)
splitter.warm_up()
result = splitter.run(documents=[doc])
Read chunks from result["documents"]. Choose overlap and threshold in the same units as the split mode.
Limits and open questions
- ChromaDocumentStore and PineconeDocumentStore have limited support: overlap information is not stored.
- A page-spanning chunk reports the page where its text starts, not every page it spans.
- Token-mode strings such as
<|endoftext|>are preserved, encoded as ordinary text, and counted toward the token limit. - The page does not prescribe an ideal retrieval chunk size.
Not for: Haystack 1.x PreProcessor or semantic EmbeddingBasedDocumentSplitter.
Sources
- DocumentSplitter guide, deepset.
- PreProcessors API reference: DocumentSplitter, deepset.
Checked
2026-11-17; read the linked DocumentSplitter guide, PreProcessors API reference: DocumentSplitter; no command was run.
Started from a post by @deepset, packaged by the editor. Original post