Qdrant: `in` filter with an empty list matches all documents (delete_by_filter deletes everything)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start by reading the Qdrant filter converter and the existing Elasticsearch handling for an empty should; compare their behavior with InMemoryDocumentStore. Add coverage for in [] and its negation, then check filtering, counting, and deletion so an empty list matches no documents and its negation matches all. The issue says the reporter already has a fix with tests ready, so check whether that work has moved to a pull request before starting.
Written by the indexing model from the issue text.
Description
Describe the bug
In QdrantDocumentStore, a filter with "operator": "in" and an empty list matches every document instead of none. The converter builds Filter(should=[]), and Qdrant treats an empty should as no condition.
This is easy to hit when the list is built at runtime (for example allowed file ids or user ids that turn out empty). It is worst with delete_by_filter(), which then deletes the whole collection. count_documents_by_filter() and retrievers are affected the same way, and NOT around such a filter returns nothing.
InMemoryDocumentStore returns no documents for in [], and the Elasticsearch filters already handle this case explicitly ("An empty should would match every document").
To Reproduce
from haystack import Document
from haystack_integrations.document_stores.qdrant import QdrantDocumentStore
store = QdrantDocumentStore(location=":memory:", embedding_dim=4, recreate_index=True)
store.write_documents([Document(content=f"doc {i}", meta={"file_id": f"f{i}"}) for i in range(3)])
f = {"field": "meta.file_id", "operator": "in", "value": []}
print(len(store.filter_documents(f))) # 3, expected 0
print(store.count_documents_by_filter(f)) # 3, expected 0
print(store.delete_by_filter(f)) # 3, expected 0
print(store.count_documents()) # 0, expected 3
Expected behavior
in [] matches no documents (and NOT of it matches all), like InMemoryDocumentStore.
Additional context
Seen on main (02bb4f7) with qdrant-client 1.20.0, both with location=":memory:" and a local Qdrant 1.20.0 server. A small fix is to return FieldCondition(key=..., match=MatchAny(any=[])) for an empty list, which matches nothing in both modes. I have a fix with tests ready and will open a PR.
- Dominant language
- Python
- Stars
- 212
- Forks
- 396
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 95
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-core-integrations
-
integration:qdrant P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepset-ai/haystack-core-integrations#4228 · 4 comments ·
Maintainers usually reply within 1 day
-
FAISS: filtered search misses matching documents outside the first top_k * 10 neighboursPossibly taken @davidsbatista claimed this 2 days ago. Open
deepset-ai/haystack-core-integrations#4322 · 1 assignee ·
Maintainers usually reply within 1 day
-
Add Late Interaction Qdrant RetrieverPossibly taken @anakin87 claimed this 6 days ago. Open
deepset-ai/haystack-core-integrations#4307 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Ollama - `OllamaChatGenerator` returns `finish_reason=None` when output is truncated (`done_reason="length"`)Possibly taken @davidsbatista claimed this 6 days ago. Open
deepset-ai/haystack-core-integrations#4302 · 1 assignee ·
Maintainers usually reply within 1 day
-
Retrievers treat `run(top_k=0)` as unset because of `top_k or self.top_k`Possibly taken @bogdankostic claimed this 8 days ago. OpenP3
Difficulty 4/5 3-5 days Newbie friendliness 48/100
deepset-ai/haystack-core-integrations#4273 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in deepset-ai/haystack-core-integrations
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