Skip to content

fix: qdrant - match numeric filter values with a closed range - #4161

Merged
davidsbatista merged 3 commits into
deepset-ai:mainfrom
inamdarmihir:fix/qdrant-numeric-filter-match
Nov 9, 2026
Merged

davidsbatista merged 3 commits into
deepset-ai:mainfrom
inamdarmihir:fix/qdrant-numeric-filter-match

Conversation

@inamdarmihir

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

QdrantDocumentStore built a MatchValue for every ==, !=, in and not in value. MatchValue only accepts str, int and bool, which caused two problems:

  1. A float value raised a pydantic ValidationError.
  2. An int value did not match float payloads, so == 4 skipped a document stored with 4.0.

_build_eq_condition now matches numeric non-bool values with a closed range, Range(gte=value, lte=value). Qdrant compares ranges numerically against int and float payloads, and for array payloads it matches any element, as MatchValue does. !=, in and not in go through _build_eq_condition, so they get the same behaviour without further changes.

Strings and bools keep MatchValue. Ints with abs(value) > 2**53 also keep MatchValue, because the server compares ranges as float64 and a range on 2**60 would also match 2**60 + 1.

How did you test it?

  • Unit tests in integrations/qdrant/tests/test_filters.py for the generated conditions: numeric == uses a range; bools, strings and ints above 2**53 keep MatchValue; in, not in and != with mixed numerics.
  • :memory: tests against payloads [3, 4, 4.0, 4.5]: == 4 returns [4, 4.0], == 4.5 returns [4.5], and !=, in and not in behave consistently. == True does not match a payload of 1.
  • Before the fix, tests/test_filters.py gave 15 failed and 73 passed, all from pydantic ValidationError on float values. After the fix it gives 88 passed and 1 skipped, and pytest tests -m "not integration" gives 156 passed. ruff check and ruff format --check pass on the touched files.
  • I only ran local :memory: mode, not a Qdrant server.

Notes for the reviewer

The new :memory: tests live in TestQdrantFilters, which is marked integration but runs in :memory: mode.

Authored by Mihir Inamdar.

Checklist

@inamdarmihir
inamdarmihir requested a review from a team as a code owner October 26, 2026 04:38
@inamdarmihir
inamdarmihir requested review from davidsbatista and removed request for a team October 26, 2026 04:38
@github-actions

Copy link
Copy Markdown
Contributor

Hi @inamdarmihir, thanks for your interest in contributing to Haystack! 🙏

⚠️ Issue #4096 is already being addressed by open pull request(s) #2. Before opening a PR for an issue, please check whether a PR is already linked to it, and consider contributing to the existing PR instead. We may close duplicate PRs to keep the review queue manageable.

This is an automated message to help us keep the review queue healthy.

@CLAassistant

CLAassistant commented Oct 26, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

MatchValue rejects floats and does not match float payloads for int values. Build a closed Range(gte=v, lte=v) for numeric non-bool values in ==, !=, in and not in. Strings, bools and ints beyond 2**53 (not exactly representable as float64 on the server) keep MatchValue.

Fixes deepset-ai#4096
@inamdarmihir
inamdarmihir force-pushed the fix/qdrant-numeric-filter-match branch from c4c07c6 to c790089 Compare October 26, 2026 04:48
@github-actions

github-actions Bot commented Oct 26, 2026 •

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

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @inamdarmihir, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from davidsbatista October 26, 2026 05:55
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 26, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 26, 2026 05:55
@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @inamdarmihir, just a friendly reminder: this PR is still in draft because the Contributor License Agreement (CLA) hasn't been signed yet. We'd love to review your contribution! Please sign the CLA via the link in the license/cla check, and this PR will automatically be marked ready for review.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @inamdarmihir, this PR is still waiting for the Contributor License Agreement (CLA) to be signed. Please note that if the CLA isn't signed within the next 4 days, this PR will be automatically closed as stale. Signing only takes a minute via the link in the license/cla check, and the PR will then automatically be marked ready for review.

@inamdarmihir
inamdarmihir marked this pull request as ready for review November 5, 2026 05:52
@HaystackBot
HaystackBot marked this pull request as draft November 5, 2026 06:31
@HaystackBot
HaystackBot marked this pull request as ready for review November 5, 2026 09:19
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Nov 5, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

Thanks for signing the CLA, @inamdarmihir! 🎉 This PR is now ready for review again and the reviewer has been re-assigned.

…lter-match

# Conflicts:
#	integrations/qdrant/tests/test_filters.py

@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.

thanks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

QdrantDocumentStore: a float filter value crashes, and an int filter misses float metadata

4 participants