Skip to content

fix: treat missing field as count 0 for values_count filter - #9607

Merged
generall merged 1 commit into
test/values-count-missing-field-9586from
fix/values-count-missing-field-9586
Jun 29, 2026
Merged

generall merged 1 commit into
test/values-count-missing-field-9586from
fix/values-count-missing-field-9586

Conversation

@generall

Copy link
Copy Markdown
Member

What

Fixes the values_count filter so a point whose payload field is missing is treated as having a value count of 0, instead of never matching.

Targets the regression-test branch test/values-count-missing-field-9586 (the test added there currently fails against master).

Root cause

FieldCondition::check_empty() in lib/segment/src/payload_storage/condition_checker.rs ignored the values_count field. When a point has no value for the queried key, check_field_condition() short-circuits to check_empty(), which returned false — so values_count bounds were never evaluated for missing fields.

Fix

Forward the empty check to the already-existing ValuesCount::check_empty() (which evaluates the bounds against a count of 0). Now:

  • {"lt": 1} matches a missing field (0 < 1)
  • {"gte": 0} matches a missing field (0 >= 0)
  • {"lte": 0} matches a missing field (0 <= 0)
  • {"gte": 1} does not match a missing field (0 >= 1 is false)

Tests

  • Added test_value_count_missing_field unit test in condition_checker.rs.
  • Makes the openapi regression test test_filter_values_count_missing_field.py (added on the base branch) pass.

Fixes #9586

🤖 Generated with Claude Code

`FieldCondition::check_empty()` ignored the `values_count` condition, so a
point with a missing payload field was never matched by a `values_count`
filter. The desired semantics (and the existing `ValuesCount::check_empty`)
treat a missing field as having a value count of 0.

Forward the empty check to `values_count.check_empty()` so bounds like
`lt: 1`, `gte: 0` and `lte: 0` correctly match points whose field is absent.

Fixes #9586

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • dev
  • master
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 4753a960-b139-4ce5-885e-55734c42287a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@generall
generall merged commit 0ec699c into test/values-count-missing-field-9586 Jun 29, 2026
15 checks passed
@generall
generall deleted the fix/values-count-missing-field-9586 branch June 29, 2026 06:46
generall added a commit that referenced this pull request Jun 29, 2026
…9606)

* test: add openapi regression test for values_count on missing fields

Reproduces #9586 where points with
a missing payload field are not matched by values_count filters that should
treat the count as 0.

Co-authored-by: Cursor <[email protected]>

* test: use module fixture for values_count missing field test

Follow the standard openapi test structure with setup/teardown fixture
instead of explicit drop_collection calls in the test body.

Co-authored-by: Cursor <[email protected]>

* fix: treat missing field as count 0 for values_count filter (#9607)

`FieldCondition::check_empty()` ignored the `values_count` condition, so a
point with a missing payload field was never matched by a `values_count`
filter. The desired semantics (and the existing `ValuesCount::check_empty`)
treat a missing field as having a value count of 0.

Forward the empty check to `values_count.check_empty()` so bounds like
`lt: 1`, `gte: 0` and `lte: 0` correctly match points whose field is absent.

Fixes #9586

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Andrey Vasnetsov <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
generall added a commit that referenced this pull request Aug 4, 2026
…9606)

* test: add openapi regression test for values_count on missing fields

Reproduces #9586 where points with
a missing payload field are not matched by values_count filters that should
treat the count as 0.

Co-authored-by: Cursor <[email protected]>

* test: use module fixture for values_count missing field test

Follow the standard openapi test structure with setup/teardown fixture
instead of explicit drop_collection calls in the test body.

Co-authored-by: Cursor <[email protected]>

* fix: treat missing field as count 0 for values_count filter (#9607)

`FieldCondition::check_empty()` ignored the `values_count` condition, so a
point with a missing payload field was never matched by a `values_count`
filter. The desired semantics (and the existing `ValuesCount::check_empty`)
treat a missing field as having a value count of 0.

Forward the empty check to `values_count.check_empty()` so bounds like
`lt: 1`, `gte: 0` and `lte: 0` correctly match points whose field is absent.

Fixes #9586

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Andrey Vasnetsov <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant