Skip to content

fix: ensure deleted chunks are not returned in retrieval (#12520)#12546

Merged
KevinHuSh merged 4 commits intoinfiniflow:mainfrom
VedantMadane:fix/deleted-chunks-retrieval-12520
Jan 15, 2026
Merged

fix: ensure deleted chunks are not returned in retrieval (#12520)#12546
KevinHuSh merged 4 commits intoinfiniflow:mainfrom
VedantMadane:fix/deleted-chunks-retrieval-12520

Conversation

@VedantMadane
Copy link
Contributor

Summary

Fixes #12520 - Deleted chunks should not appear in retrieval/reference results.

Changes

Core Fix

  • api/apps/chunk_app.py: Include \doc_id\ in delete condition to properly scope the delete operation

Improved Error Handling

  • api/db/services/document_service.py: Better separation of concerns with individual try-catch blocks and proper logging for each cleanup operation

Doc Store Updates

  • rag/utils/es_conn.py: Updated delete query construction to support compound conditions
  • rag/utils/opensearch_conn.py: Same updates for OpenSearch compatibility

Tests

  • test/testcases/.../test_retrieval_chunks.py: Added \TestDeletedChunksNotRetrievable\ class with regression tests
  • test/unit/test_delete_query_construction.py: Unit tests for delete query construction

Testing

  • Added regression tests that verify deleted chunks are not returned by retrieval API
  • Tests cover single chunk deletion and batch deletion scenarios

…12520)

- Include doc_id in delete condition in chunk_app.py to properly scope deletes
- Improve error handling in document_service.py with better separation and logging
- Update es_conn.py and opensearch_conn.py to support scoped deletes
- Add regression tests for deleted chunk retrieval behavior

Fixes infiniflow#12520
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jan 10, 2026
@KevinHuSh KevinHuSh requested a review from asiroliu January 12, 2026 02:45
@KevinHuSh KevinHuSh added the ci Continue Integration label Jan 14, 2026
@KevinHuSh KevinHuSh marked this pull request as draft January 14, 2026 02:01
@KevinHuSh KevinHuSh marked this pull request as ready for review January 14, 2026 02:02
@KevinHuSh
Copy link
Collaborator

Appreciation!
CI failure!

@VedantMadane
Copy link
Contributor Author

VedantMadane commented Jan 14, 2026

CI failure!

Fixed.

@VedantMadane VedantMadane reopened this Jan 14, 2026
@asiroliu asiroliu requested a review from 6ba3i January 15, 2026 03:21
@KevinHuSh KevinHuSh merged commit ac93600 into infiniflow:main Jan 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Files of deleted slices can still be searched and displayed in "reference"

2 participants