Skip to content

fix: Qdrant - match no documents for an empty in filter - #4346

Open
astroknot-sheep wants to merge 1 commit into
deepset-ai:mainfrom
astroknot-sheep:fix/qdrant-empty-in-filter
Open

astroknot-sheep wants to merge 1 commit into
deepset-ai:mainfrom
astroknot-sheep:fix/qdrant-empty-in-filter

Conversation

@astroknot-sheep

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

_build_in_condition returned Filter(should=[...]). For an empty list this is Filter(should=[]), which Qdrant treats as no condition, so in [] matched every point. Through delete_by_filter() this deleted the whole collection.

Now an empty list gives FieldCondition(key=key, match=MatchAny(any=[])), which matches nothing. Non-empty lists and not in are unchanged. All sync and async paths (filter_documents, count_documents_by_filter, delete_by_filter, update_by_filter, retrievers) use the same converter, so they are all fixed.

How did you test it?

  • Added a unit test for the converted filter and an integration test (:memory:) checking filter_documents, count_documents_by_filter, NOT of the filter and delete_by_filter. Both fail on main and pass with this change.
  • In integrations/qdrant: full pytest tests 424 passed, 1 skipped (with a local Qdrant 1.20.0 server running); ruff check, ruff format --check and mypy (the types script) clean.
  • Also checked that MatchAny(any=[]) matches no points on a real Qdrant 1.20.0 server, not only in local mode.

Notes for the reviewer

I used AI assistance while investigating and drafting this PR. I reviewed every line and ran the tests myself.

Checklist

@astroknot-sheep
astroknot-sheep requested a review from a team as a code owner November 27, 2026 15:25
@astroknot-sheep
astroknot-sheep requested review from julian-risch and removed request for a team November 27, 2026 15:25
@astroknot-sheep astroknot-sheep changed the title ## Related Issues fix: Qdrant - match no documents for an empty in filter Nov 27, 2026
@github-actions github-actions Bot added the type:documentation Improvements or additions to documentation label Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (qdrant)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/qdrant/src/haystack_integrations/document_stores/qdrant
  filters.py
Project Total  

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:qdrant type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Qdrant: in filter with an empty list matches all documents (delete_by_filter deletes everything)

1 participant