Skip to content

fix: populate split_idx_start metadata in EmbeddingBasedDocumentSplitter#11987

Merged
davidsbatista merged 2 commits into
deepset-ai:mainfrom
rautaditya2606:fix/embedding-splitter-missing-split-idx-start
Jul 17, 2026
Merged

fix: populate split_idx_start metadata in EmbeddingBasedDocumentSplitter#11987
davidsbatista merged 2 commits into
deepset-ai:mainfrom
rautaditya2606:fix/embedding-splitter-missing-split-idx-start

Conversation

@rautaditya2606

Copy link
Copy Markdown
Contributor

Related Issues

Fixes #11986


Proposed Changes

  • Populate split_idx_start while creating output documents by tracking the accumulated character offset.
  • Update the run() and run_async() docstrings to document the additional metadata field.
  • Add two regression tests:
    • test_create_documents_from_splits_split_idx_start
    • test_run_split_idx_start
  • Add a release note.

How did you test it?

hatch run test:unit test/components/preprocessors/test_embedding_based_document_splitter.py -k "not integration"

37 tests passed, 10 integration tests deselected.


Notes for the reviewer

This change makes EmbeddingBasedDocumentSplitter emit split_idx_start consistently with the other splitter implementations.

Since the splitter constructs chunks through pure string concatenation without modifying or reordering text, the character offset is readily available by accumulating the lengths of the emitted chunks. The added regression tests verify both the metadata and that each reported offset correctly indexes into the original document.


Checklist

  • Read contributors guidelines and code of conduct
  • Updated related issue
  • Added unit tests
  • Used conventional commit type in PR title
  • Documented code
  • Added release note
  • Run pre-commit hooks and fixed any issues

Copilot AI review requested due to automatic review settings July 13, 2026 12:25
@rautaditya2606
rautaditya2606 requested a review from a team as a code owner July 13, 2026 12:25
@rautaditya2606
rautaditya2606 requested review from davidsbatista and removed request for a team July 13, 2026 12:25
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

@rautaditya2606 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes inconsistency in splitter output metadata by adding split_idx_start to EmbeddingBasedDocumentSplitter chunks, aligning it with other splitter implementations and preventing downstream KeyErrors when consumers expect character offsets.

Changes:

  • Populate split_idx_start for each emitted chunk by accumulating character offsets in _create_documents_from_splits().
  • Document the new metadata field in run() / run_async() docstrings.
  • Add unit regression tests covering both the internal chunk creation and the public run() output, plus a release note.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
haystack/components/preprocessors/embedding_based_document_splitter.py Adds split_idx_start metadata and updates docstrings to describe the new field.
test/components/preprocessors/test_embedding_based_document_splitter.py Adds regression tests asserting split_idx_start presence and correctness (including indexing back into the source text).
releasenotes/notes/fix-embedding-splitter-missing-split-idx-start-8727a44789f5256a.yaml Release note documenting the bugfix and downstream impact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/preprocessors
  embedding_based_document_splitter.py
  haystack/core/pipeline
  pipeline.py
Project Total  

This report was generated by python-coverage-comment-action

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
haystack-docs Ready Ready Preview, Comment Jul 17, 2026 9:02am

Request Review

@davidsbatista davidsbatista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the fix!

@davidsbatista
davidsbatista merged commit c9966a9 into deepset-ai:main Jul 17, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

EmbeddingBasedDocumentSplitter does not populate split_idx_start metadata for output chunks

3 participants