DocumentSplitter misplaces repeated literal chunks from an overlapping custom splitter
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Read the custom split offset lookup in haystack/components/preprocessors/document_splitter.py around lines 349–373 and the existing sliding-window test in test/components/preprocessors/test_document_splitter.py around lines 346–371. Start by running that test and adapting its case to repeated overlapping chunks. The fix is done when the four chunks start at [0, 3, 6, 9], their overlap metadata matches those source ranges, and the retriever returns go go go go go go.
Written by the indexing model from the issue text.
Description
Describe the bug
When a custom DocumentSplitter callback returns overlapping windows of repeated text, later copies can be picked in place of the actual overlapping windows. Some split_idx_start values then point beyond the source. A SentenceWindowRetriever using those chunks returns duplicated text.
Error message
No exception is raised.
Expected behavior
The four windows below have exactly four increasing literal source starts, [0, 3, 6, 9]. Their overlap metadata should describe those ranges, and the retrieved window should be go go go go go go. The existing custom-splitter test checks source offsets and overlap metadata for a sliding window with distinct text. Existing sliding-window test
Additional context
The splitter searches from the end of the previous chunk and only tries an earlier overlap when that search fails. For the second chunk below, it finds a later occurrence at offset 9. The third and fourth chunks then take the running fallback offsets, 17 and 25. Built-in word splitting with the same source and window sizes gives the expected offsets and text. Custom split offset lookup
To Reproduce
from haystack import Document
from haystack.components.preprocessors import DocumentSplitter
from haystack.components.retrievers import SentenceWindowRetriever
from haystack.document_stores.in_memory import InMemoryDocumentStore
def sliding_window(text):
words = text.split(" ")
return [" ".join(words[i : i + 3]) for i in range(len(words) - 2)]
text = "go go go go go go"
splitter = DocumentSplitter(
split_by="function",
splitting_function=sliding_window,
split_length=3,
split_overlap=2,
)
chunks = splitter.run(documents=[Document(content=text)])["documents"]
store = InMemoryDocumentStore()
store.write_documents(chunks)
retriever = SentenceWindowRetriever(document_store=store, window_size=len(chunks))
result = retriever.run(retrieved_documents=[chunks[2]])
print([chunk.meta["split_idx_start"] for chunk in chunks])
print(result["context_windows"][0])
Output on main:
[0, 9, 17, 25]
go go gogo go gogo go gogo go go
FAQ Check
- Read the Haystack FAQ.
System
- Ubuntu 24.04.2 LTS, x86_64
- Python 3.12.14
- Haystack main at
bbf5b2b429670fa866e388f9a734ff3b1c652bf8(VERSION.txtreports3.6.0-rc0)
OpenAI Codex prepared and ran the reproduction.
- Dominant language
- Python
- Stars
- 27.1k
- Forks
- 3.5k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 239
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from deepset-ai/haystack
-
BlockingConfirmationStrategy ignores an empty argument replacementPossibly taken @Aarkin7 claimed this 3 days ago. Open
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
deepset-ai/haystack#13863 · 2 comments ·
Maintainers usually reply within 1 day
-
P2
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
deepset-ai/haystack#13830 · 4 comments ·
Maintainers usually reply within 1 day
-
CSVToDocument accepts an unsupported conversion_mode and silently converts in row modePossibly taken @Lesereingrape claimed this 54 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
deepset-ai/haystack#13070 ·
Maintainers usually reply within 1 day
-
InMemoryDocumentStore: count_unique_metadata_by_filter and get_metadata_field_unique_values disagree on int/float/bool valuesPossibly taken @sjrl claimed this 14 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepset-ai/haystack#13040 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
CSVToDocument row mode fails on CR-separated CSV inputPossibly taken @julian-risch claimed this 55 days ago. OpenP3
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
deepset-ai/haystack#13022 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in deepset-ai/haystack
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/graphon#443 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authenticationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
docling-project/docling-serve#788 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainers usually reply within 1 day