Skip to content

refactor(field_index): migrate FullTextIndex into condition_checker - #8984

Merged
generall merged 2 commits into
condition-checker-boolfrom
condition-checker-fulltext
May 11, 2026
Merged

generall merged 2 commits into
condition-checker-boolfrom
condition-checker-fulltext

Conversation

@generall

Copy link
Copy Markdown
Member

Summary

Sub-plan PR 6 of condition-checker-migration. `FullTextIndex` now serves `Match::Text` / `Match::TextAny` / `Match::Phrase` directly through `PayloadFieldIndexRead::condition_checker`.

Stacked on #8983 → #8982 → #8981 → #8980 → #8979 → #8978 → dev.

What changed

  1. `impl PayloadFieldIndexRead for FullTextIndex` gains a `condition_checker` override. Explicit `FieldCondition` destructure (no `..`) plus exhaustive `Match` variant matching (no `_ => None`). `Match::Value` / `Match::Any` / `Match::Except` return `None` explicitly. Body copies `parse_text_query` / `parse_phrase_query` / `parse_text_any_query` dispatch and the `check_match` closure from the legacy helper, preserving the FIXME-marked error swallowing.

  2. `match_converter.rs` loses `get_match_text_checker` and the `TextQueryType` enum (both unused after this PR). `get_match_checkers`' Text/TextAny/Phrase arms collapse to a single explicit `None` arm.

Test plan

  • `cargo build --workspace --tests` (clean)
  • `cargo nextest run -p segment` — 786/786 pass
  • `cargo +nightly fmt --all -- --check`

🤖 Generated with Claude Code

generall added a commit that referenced this pull request May 10, 2026
Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@generall
generall force-pushed the condition-checker-fulltext branch from 48dc1be to 79dd56f Compare May 10, 2026 21:40
@generall
generall force-pushed the condition-checker-bool branch from 977c902 to 85b2a92 Compare May 10, 2026 21:40
…condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 10, 2026
Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@generall
generall force-pushed the condition-checker-fulltext branch from 79dd56f to 406d6a6 Compare May 10, 2026 22:03
generall added a commit that referenced this pull request May 11, 2026
…ndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
…rs (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@generall
generall merged commit 5a8b5ae into condition-checker-bool May 11, 2026
11 checks passed
@generall
generall deleted the condition-checker-fulltext branch May 11, 2026 17:56
generall added a commit that referenced this pull request May 11, 2026
* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 11, 2026
* refactor(field_index): migrate MapIndex condition checking into condition_checker

Sub-plan PR 4 of the condition-checker-migration. MapIndex<K> now
serves Match::Value / Match::Any / Match::Except conditions directly
through PayloadFieldIndexRead::condition_checker, one override per K
(MapIndex<str>, MapIndex<UuidIntType>, MapIndex<IntPayloadType>).

Changes:

1. Three impl blocks gain condition_checker overrides — one per K.
   Each uses an explicit FieldCondition destructure (no `..`) and an
   exhaustive `Match` variant match (no `_ => None`); a new variant
   in FieldCondition, Match, ValueVariants, or AnyVariants forces a
   compile error in every relevant place. INDEXSET_ITER_THRESHOLD
   small/large branching preserved.

2. read_view/condition_converter/match_converter.rs sheds the Map
   arms. get_match_value_checker keeps (Bool, BoolIndex) plus the
   explicit 30-tuple None list. get_match_any_checker becomes an
   explicit 22-tuple None match (no Bool/FullText/Numeric/Geo/Null
   variant ever served Any). get_match_except_checker reduces to the
   unconditional values_count > 0 fallback — when no typed index
   handles Except (via condition_checker), match any point with at
   least one value, since the value can't be in a type-mismatched
   list. Unused IndexSet/Uuid/INDEXSET_ITER_THRESHOLD imports drop.

Stacked on #8981 (NumericIndex) → #8980 (NullIndex) → #8979
(GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate BoolIndex into condition_checker (#8983)

* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 11, 2026
…8981)

* refactor(field_index): migrate NumericIndex condition checking into condition_checker

Sub-plan PR 3 of the condition-checker-migration. NumericIndexInner<T>
now serves Range conditions directly through
PayloadFieldIndexRead::condition_checker. The generic impl handles all
four FieldIndex variants (IntIndex, FloatIndex, DatetimeIndex,
UuidIndex) with one trait override.

Changes:

1. impl PayloadFieldIndexRead for NumericIndexInner<T> gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) binds `range`. Body converts the RangeInterface bounds
   into T via T::from_f64 / T::from_u128 — same conversion `filter`
   already uses.

2. read_view/condition_converter/helpers.rs drops the range arm from
   field_condition_index's legacy match and deletes
   get_range_checkers / get_float_range_checkers /
   get_datetime_range_checkers (3 helpers, ~75 lines). Six unused
   imports go with them.

Behavioural note: The legacy helpers were stricter than `filter` —
only IntIndex/FloatIndex served Float ranges, only DatetimeIndex
served DateTime ranges; UuidIndex returned None. `filter` already
handles every numeric variant uniformly via T::from_f64 / T::from_u128,
so there was a pre-existing inconsistency between filter (primary-
clause iteration) and condition_checker (post-filter validation).
This PR makes condition_checker match filter — every NumericIndex
variant can now serve any RangeInterface. The schema layer normally
prevents cross-type range queries from reaching here.

Stacked on #8980 (NullIndex) → #8979 (GeoMapIndex) → #8978
(foundation) → dev.

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

* refactor(field_index): migrate MapIndex into condition_checker (#8982)

* refactor(field_index): migrate MapIndex condition checking into condition_checker

Sub-plan PR 4 of the condition-checker-migration. MapIndex<K> now
serves Match::Value / Match::Any / Match::Except conditions directly
through PayloadFieldIndexRead::condition_checker, one override per K
(MapIndex<str>, MapIndex<UuidIntType>, MapIndex<IntPayloadType>).

Changes:

1. Three impl blocks gain condition_checker overrides — one per K.
   Each uses an explicit FieldCondition destructure (no `..`) and an
   exhaustive `Match` variant match (no `_ => None`); a new variant
   in FieldCondition, Match, ValueVariants, or AnyVariants forces a
   compile error in every relevant place. INDEXSET_ITER_THRESHOLD
   small/large branching preserved.

2. read_view/condition_converter/match_converter.rs sheds the Map
   arms. get_match_value_checker keeps (Bool, BoolIndex) plus the
   explicit 30-tuple None list. get_match_any_checker becomes an
   explicit 22-tuple None match (no Bool/FullText/Numeric/Geo/Null
   variant ever served Any). get_match_except_checker reduces to the
   unconditional values_count > 0 fallback — when no typed index
   handles Except (via condition_checker), match any point with at
   least one value, since the value can't be in a type-mismatched
   list. Unused IndexSet/Uuid/INDEXSET_ITER_THRESHOLD imports drop.

Stacked on #8981 (NumericIndex) → #8980 (NullIndex) → #8979
(GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate BoolIndex into condition_checker (#8983)

* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 11, 2026
* refactor(field_index): migrate NullIndex condition checking into condition_checker

Sub-plan PR 2 of the condition-checker-migration. NullIndex now
serves is_empty / is_null conditions directly through
PayloadFieldIndexRead::condition_checker. The dispatch in the read
view's condition_converter/mod.rs collapses to mirror the
Condition::Field arm: try every index for the field, fall back to
the payload check on unwrap_or_else.

Changes:

1. impl PayloadFieldIndexRead for NullIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) — binds
   is_empty and is_null, every other field uses `_:` to document
   intentional non-handling.

2. read_view/condition_converter/helpers.rs drops the is_empty /
   is_null arms from field_condition_index's legacy match and deletes
   five orphaned helpers: get_is_empty_checker, get_is_null_checker,
   get_is_empty_indexes, get_null_index_is_empty_checker,
   get_fallback_is_empty_checker.

3. read_view/condition_converter/mod.rs rewrites Condition::IsEmpty
   and Condition::IsNull to use field_condition_index with a
   constructed FieldCondition, same shape as Condition::Field.

Behavioural note (decision locked during review): The legacy
values_is_empty fast-path for "field has indexes but no NullIndex"
is dropped. NullIndex was introduced in v1.13.5 (#6088); we're on
v1.18.0, so any collection touched in the past ~5 minor releases has
a NullIndex. Segments untouched since pre-v1.13.5 fall through to the
payload check on is_empty queries — no longer accelerated by another
index's values_is_empty. A re-index recovers the original perf.

Stacked on #8979 (GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate NumericIndex into condition_checker (#8981)

* refactor(field_index): migrate NumericIndex condition checking into condition_checker

Sub-plan PR 3 of the condition-checker-migration. NumericIndexInner<T>
now serves Range conditions directly through
PayloadFieldIndexRead::condition_checker. The generic impl handles all
four FieldIndex variants (IntIndex, FloatIndex, DatetimeIndex,
UuidIndex) with one trait override.

Changes:

1. impl PayloadFieldIndexRead for NumericIndexInner<T> gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) binds `range`. Body converts the RangeInterface bounds
   into T via T::from_f64 / T::from_u128 — same conversion `filter`
   already uses.

2. read_view/condition_converter/helpers.rs drops the range arm from
   field_condition_index's legacy match and deletes
   get_range_checkers / get_float_range_checkers /
   get_datetime_range_checkers (3 helpers, ~75 lines). Six unused
   imports go with them.

Behavioural note: The legacy helpers were stricter than `filter` —
only IntIndex/FloatIndex served Float ranges, only DatetimeIndex
served DateTime ranges; UuidIndex returned None. `filter` already
handles every numeric variant uniformly via T::from_f64 / T::from_u128,
so there was a pre-existing inconsistency between filter (primary-
clause iteration) and condition_checker (post-filter validation).
This PR makes condition_checker match filter — every NumericIndex
variant can now serve any RangeInterface. The schema layer normally
prevents cross-type range queries from reaching here.

Stacked on #8980 (NullIndex) → #8979 (GeoMapIndex) → #8978
(foundation) → dev.

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

* refactor(field_index): migrate MapIndex into condition_checker (#8982)

* refactor(field_index): migrate MapIndex condition checking into condition_checker

Sub-plan PR 4 of the condition-checker-migration. MapIndex<K> now
serves Match::Value / Match::Any / Match::Except conditions directly
through PayloadFieldIndexRead::condition_checker, one override per K
(MapIndex<str>, MapIndex<UuidIntType>, MapIndex<IntPayloadType>).

Changes:

1. Three impl blocks gain condition_checker overrides — one per K.
   Each uses an explicit FieldCondition destructure (no `..`) and an
   exhaustive `Match` variant match (no `_ => None`); a new variant
   in FieldCondition, Match, ValueVariants, or AnyVariants forces a
   compile error in every relevant place. INDEXSET_ITER_THRESHOLD
   small/large branching preserved.

2. read_view/condition_converter/match_converter.rs sheds the Map
   arms. get_match_value_checker keeps (Bool, BoolIndex) plus the
   explicit 30-tuple None list. get_match_any_checker becomes an
   explicit 22-tuple None match (no Bool/FullText/Numeric/Geo/Null
   variant ever served Any). get_match_except_checker reduces to the
   unconditional values_count > 0 fallback — when no typed index
   handles Except (via condition_checker), match any point with at
   least one value, since the value can't be in a type-mismatched
   list. Unused IndexSet/Uuid/INDEXSET_ITER_THRESHOLD imports drop.

Stacked on #8981 (NumericIndex) → #8980 (NullIndex) → #8979
(GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate BoolIndex into condition_checker (#8983)

* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 11, 2026
)

* refactor(field_index): migrate GeoMapIndex condition checking into condition_checker

Sub-plan PR 1 of the condition-checker-migration. GeoMapIndex now
serves geo conditions (geo_radius, geo_bounding_box, geo_polygon)
directly through PayloadFieldIndexRead::condition_checker. The
corresponding match arms and three helper functions in the read
view's helpers.rs are gone — the polymorphic dispatch in
field_condition_index handles them.

Changes:

1. impl PayloadFieldIndexRead for GeoMapIndex gains a condition_checker
   override. Bodies copied from get_geo_radius_checkers /
   get_geo_bounding_box_checkers / get_geo_polygon_checkers; the
   `&'a self` capture replaces the &FieldIndex match arm.

2. The override destructures FieldCondition explicitly (no `..`,
   every field named with either a binding or `_:`). This forces a
   compile error if a new field is added to FieldCondition, so each
   index variant must explicitly decide whether to handle it. Same
   pattern is mandated for the remaining variant migrations — see
   docs/plans/field-index-read-trait/condition-checker-migration/00-overview.md.

3. read_view/condition_converter/helpers.rs drops the three Geo
   FieldCondition arms from field_condition_index's legacy match
   and deletes the three helper functions. The catch-all is relaxed
   to `geo_radius: _ | geo_bounding_box: _ | geo_polygon: _` since
   the trait method handles all geo cases now.

No behavioural change: non-Geo variants continue to return None for
geo conditions (the trait default returns None), and the read view's
catch-all still falls back to the payload check.

Stacked on #8978 (condition-checker-trait foundation).

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

* refactor(field_index): migrate NullIndex into condition_checker (#8980)

* refactor(field_index): migrate NullIndex condition checking into condition_checker

Sub-plan PR 2 of the condition-checker-migration. NullIndex now
serves is_empty / is_null conditions directly through
PayloadFieldIndexRead::condition_checker. The dispatch in the read
view's condition_converter/mod.rs collapses to mirror the
Condition::Field arm: try every index for the field, fall back to
the payload check on unwrap_or_else.

Changes:

1. impl PayloadFieldIndexRead for NullIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) — binds
   is_empty and is_null, every other field uses `_:` to document
   intentional non-handling.

2. read_view/condition_converter/helpers.rs drops the is_empty /
   is_null arms from field_condition_index's legacy match and deletes
   five orphaned helpers: get_is_empty_checker, get_is_null_checker,
   get_is_empty_indexes, get_null_index_is_empty_checker,
   get_fallback_is_empty_checker.

3. read_view/condition_converter/mod.rs rewrites Condition::IsEmpty
   and Condition::IsNull to use field_condition_index with a
   constructed FieldCondition, same shape as Condition::Field.

Behavioural note (decision locked during review): The legacy
values_is_empty fast-path for "field has indexes but no NullIndex"
is dropped. NullIndex was introduced in v1.13.5 (#6088); we're on
v1.18.0, so any collection touched in the past ~5 minor releases has
a NullIndex. Segments untouched since pre-v1.13.5 fall through to the
payload check on is_empty queries — no longer accelerated by another
index's values_is_empty. A re-index recovers the original perf.

Stacked on #8979 (GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate NumericIndex into condition_checker (#8981)

* refactor(field_index): migrate NumericIndex condition checking into condition_checker

Sub-plan PR 3 of the condition-checker-migration. NumericIndexInner<T>
now serves Range conditions directly through
PayloadFieldIndexRead::condition_checker. The generic impl handles all
four FieldIndex variants (IntIndex, FloatIndex, DatetimeIndex,
UuidIndex) with one trait override.

Changes:

1. impl PayloadFieldIndexRead for NumericIndexInner<T> gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) binds `range`. Body converts the RangeInterface bounds
   into T via T::from_f64 / T::from_u128 — same conversion `filter`
   already uses.

2. read_view/condition_converter/helpers.rs drops the range arm from
   field_condition_index's legacy match and deletes
   get_range_checkers / get_float_range_checkers /
   get_datetime_range_checkers (3 helpers, ~75 lines). Six unused
   imports go with them.

Behavioural note: The legacy helpers were stricter than `filter` —
only IntIndex/FloatIndex served Float ranges, only DatetimeIndex
served DateTime ranges; UuidIndex returned None. `filter` already
handles every numeric variant uniformly via T::from_f64 / T::from_u128,
so there was a pre-existing inconsistency between filter (primary-
clause iteration) and condition_checker (post-filter validation).
This PR makes condition_checker match filter — every NumericIndex
variant can now serve any RangeInterface. The schema layer normally
prevents cross-type range queries from reaching here.

Stacked on #8980 (NullIndex) → #8979 (GeoMapIndex) → #8978
(foundation) → dev.

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

* refactor(field_index): migrate MapIndex into condition_checker (#8982)

* refactor(field_index): migrate MapIndex condition checking into condition_checker

Sub-plan PR 4 of the condition-checker-migration. MapIndex<K> now
serves Match::Value / Match::Any / Match::Except conditions directly
through PayloadFieldIndexRead::condition_checker, one override per K
(MapIndex<str>, MapIndex<UuidIntType>, MapIndex<IntPayloadType>).

Changes:

1. Three impl blocks gain condition_checker overrides — one per K.
   Each uses an explicit FieldCondition destructure (no `..`) and an
   exhaustive `Match` variant match (no `_ => None`); a new variant
   in FieldCondition, Match, ValueVariants, or AnyVariants forces a
   compile error in every relevant place. INDEXSET_ITER_THRESHOLD
   small/large branching preserved.

2. read_view/condition_converter/match_converter.rs sheds the Map
   arms. get_match_value_checker keeps (Bool, BoolIndex) plus the
   explicit 30-tuple None list. get_match_any_checker becomes an
   explicit 22-tuple None match (no Bool/FullText/Numeric/Geo/Null
   variant ever served Any). get_match_except_checker reduces to the
   unconditional values_count > 0 fallback — when no typed index
   handles Except (via condition_checker), match any point with at
   least one value, since the value can't be in a type-mismatched
   list. Unused IndexSet/Uuid/INDEXSET_ITER_THRESHOLD imports drop.

Stacked on #8981 (NumericIndex) → #8980 (NullIndex) → #8979
(GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate BoolIndex into condition_checker (#8983)

* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 11, 2026
#8978)

* refactor(field_index): add condition_checker trait method (foundation)

First PR in the condition-checker-migration sub-plan
(docs/plans/field-index-read-trait/condition-checker-migration/).
Purely additive: every existing typed index keeps the default `None`
impl, so the legacy match in `field_condition_index` handles every
condition. Behaviour unchanged.

Changes:

1. PayloadFieldIndexRead::condition_checker — new method with default
   `None` body. Lets each typed index advertise the conditions it can
   serve.

2. FieldIndexRead::get_payload_field_index_read — new required method
   returning `&dyn PayloadFieldIndexRead`. Distinct from the existing
   inherent `get_payload_field_index` (which returns `&dyn PayloadFieldIndex`,
   exposing write-side methods) — the read path now hands back a
   handle that can't accidentally call wipe / flusher / files.

3. Five pure-delegation methods on FieldIndexRead get default impls
   using the new getter (count_indexed_points, filter,
   estimate_cardinality, for_each_payload_block, condition_checker).
   `impl FieldIndexRead for FieldIndex` drops their explicit bodies.

4. field_condition_index in read_view/condition_converter/helpers.rs
   tries `index.condition_checker(...)` first, then falls through to
   the existing legacy match. The match handles everything until
   per-variant overrides land in the follow-up PRs.

Why `&dyn` rather than `impl PayloadFieldIndexRead + '_`: RPITIT
requires a single concrete return type, but the per-variant arms
produce `&NumericIndexInner<T>`, `&MapIndex<K>`, `&GeoMapIndex`, etc.
— different types. A unifying borrowed-enum (à la FacetIndexEnum)
would be more code than the trait-object indirection saves.

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

* refactor(field_index): migrate GeoMapIndex into condition_checker (#8979)

* refactor(field_index): migrate GeoMapIndex condition checking into condition_checker

Sub-plan PR 1 of the condition-checker-migration. GeoMapIndex now
serves geo conditions (geo_radius, geo_bounding_box, geo_polygon)
directly through PayloadFieldIndexRead::condition_checker. The
corresponding match arms and three helper functions in the read
view's helpers.rs are gone — the polymorphic dispatch in
field_condition_index handles them.

Changes:

1. impl PayloadFieldIndexRead for GeoMapIndex gains a condition_checker
   override. Bodies copied from get_geo_radius_checkers /
   get_geo_bounding_box_checkers / get_geo_polygon_checkers; the
   `&'a self` capture replaces the &FieldIndex match arm.

2. The override destructures FieldCondition explicitly (no `..`,
   every field named with either a binding or `_:`). This forces a
   compile error if a new field is added to FieldCondition, so each
   index variant must explicitly decide whether to handle it. Same
   pattern is mandated for the remaining variant migrations — see
   docs/plans/field-index-read-trait/condition-checker-migration/00-overview.md.

3. read_view/condition_converter/helpers.rs drops the three Geo
   FieldCondition arms from field_condition_index's legacy match
   and deletes the three helper functions. The catch-all is relaxed
   to `geo_radius: _ | geo_bounding_box: _ | geo_polygon: _` since
   the trait method handles all geo cases now.

No behavioural change: non-Geo variants continue to return None for
geo conditions (the trait default returns None), and the read view's
catch-all still falls back to the payload check.

Stacked on #8978 (condition-checker-trait foundation).

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

* refactor(field_index): migrate NullIndex into condition_checker (#8980)

* refactor(field_index): migrate NullIndex condition checking into condition_checker

Sub-plan PR 2 of the condition-checker-migration. NullIndex now
serves is_empty / is_null conditions directly through
PayloadFieldIndexRead::condition_checker. The dispatch in the read
view's condition_converter/mod.rs collapses to mirror the
Condition::Field arm: try every index for the field, fall back to
the payload check on unwrap_or_else.

Changes:

1. impl PayloadFieldIndexRead for NullIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) — binds
   is_empty and is_null, every other field uses `_:` to document
   intentional non-handling.

2. read_view/condition_converter/helpers.rs drops the is_empty /
   is_null arms from field_condition_index's legacy match and deletes
   five orphaned helpers: get_is_empty_checker, get_is_null_checker,
   get_is_empty_indexes, get_null_index_is_empty_checker,
   get_fallback_is_empty_checker.

3. read_view/condition_converter/mod.rs rewrites Condition::IsEmpty
   and Condition::IsNull to use field_condition_index with a
   constructed FieldCondition, same shape as Condition::Field.

Behavioural note (decision locked during review): The legacy
values_is_empty fast-path for "field has indexes but no NullIndex"
is dropped. NullIndex was introduced in v1.13.5 (#6088); we're on
v1.18.0, so any collection touched in the past ~5 minor releases has
a NullIndex. Segments untouched since pre-v1.13.5 fall through to the
payload check on is_empty queries — no longer accelerated by another
index's values_is_empty. A re-index recovers the original perf.

Stacked on #8979 (GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate NumericIndex into condition_checker (#8981)

* refactor(field_index): migrate NumericIndex condition checking into condition_checker

Sub-plan PR 3 of the condition-checker-migration. NumericIndexInner<T>
now serves Range conditions directly through
PayloadFieldIndexRead::condition_checker. The generic impl handles all
four FieldIndex variants (IntIndex, FloatIndex, DatetimeIndex,
UuidIndex) with one trait override.

Changes:

1. impl PayloadFieldIndexRead for NumericIndexInner<T> gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) binds `range`. Body converts the RangeInterface bounds
   into T via T::from_f64 / T::from_u128 — same conversion `filter`
   already uses.

2. read_view/condition_converter/helpers.rs drops the range arm from
   field_condition_index's legacy match and deletes
   get_range_checkers / get_float_range_checkers /
   get_datetime_range_checkers (3 helpers, ~75 lines). Six unused
   imports go with them.

Behavioural note: The legacy helpers were stricter than `filter` —
only IntIndex/FloatIndex served Float ranges, only DatetimeIndex
served DateTime ranges; UuidIndex returned None. `filter` already
handles every numeric variant uniformly via T::from_f64 / T::from_u128,
so there was a pre-existing inconsistency between filter (primary-
clause iteration) and condition_checker (post-filter validation).
This PR makes condition_checker match filter — every NumericIndex
variant can now serve any RangeInterface. The schema layer normally
prevents cross-type range queries from reaching here.

Stacked on #8980 (NullIndex) → #8979 (GeoMapIndex) → #8978
(foundation) → dev.

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

* refactor(field_index): migrate MapIndex into condition_checker (#8982)

* refactor(field_index): migrate MapIndex condition checking into condition_checker

Sub-plan PR 4 of the condition-checker-migration. MapIndex<K> now
serves Match::Value / Match::Any / Match::Except conditions directly
through PayloadFieldIndexRead::condition_checker, one override per K
(MapIndex<str>, MapIndex<UuidIntType>, MapIndex<IntPayloadType>).

Changes:

1. Three impl blocks gain condition_checker overrides — one per K.
   Each uses an explicit FieldCondition destructure (no `..`) and an
   exhaustive `Match` variant match (no `_ => None`); a new variant
   in FieldCondition, Match, ValueVariants, or AnyVariants forces a
   compile error in every relevant place. INDEXSET_ITER_THRESHOLD
   small/large branching preserved.

2. read_view/condition_converter/match_converter.rs sheds the Map
   arms. get_match_value_checker keeps (Bool, BoolIndex) plus the
   explicit 30-tuple None list. get_match_any_checker becomes an
   explicit 22-tuple None match (no Bool/FullText/Numeric/Geo/Null
   variant ever served Any). get_match_except_checker reduces to the
   unconditional values_count > 0 fallback — when no typed index
   handles Except (via condition_checker), match any point with at
   least one value, since the value can't be in a type-mismatched
   list. Unused IndexSet/Uuid/INDEXSET_ITER_THRESHOLD imports drop.

Stacked on #8981 (NumericIndex) → #8980 (NullIndex) → #8979
(GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate BoolIndex into condition_checker (#8983)

* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

* CI fix

* upd docstring

---------

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
generall added a commit that referenced this pull request May 22, 2026
#8978)

* refactor(field_index): add condition_checker trait method (foundation)

First PR in the condition-checker-migration sub-plan
(docs/plans/field-index-read-trait/condition-checker-migration/).
Purely additive: every existing typed index keeps the default `None`
impl, so the legacy match in `field_condition_index` handles every
condition. Behaviour unchanged.

Changes:

1. PayloadFieldIndexRead::condition_checker — new method with default
   `None` body. Lets each typed index advertise the conditions it can
   serve.

2. FieldIndexRead::get_payload_field_index_read — new required method
   returning `&dyn PayloadFieldIndexRead`. Distinct from the existing
   inherent `get_payload_field_index` (which returns `&dyn PayloadFieldIndex`,
   exposing write-side methods) — the read path now hands back a
   handle that can't accidentally call wipe / flusher / files.

3. Five pure-delegation methods on FieldIndexRead get default impls
   using the new getter (count_indexed_points, filter,
   estimate_cardinality, for_each_payload_block, condition_checker).
   `impl FieldIndexRead for FieldIndex` drops their explicit bodies.

4. field_condition_index in read_view/condition_converter/helpers.rs
   tries `index.condition_checker(...)` first, then falls through to
   the existing legacy match. The match handles everything until
   per-variant overrides land in the follow-up PRs.

Why `&dyn` rather than `impl PayloadFieldIndexRead + '_`: RPITIT
requires a single concrete return type, but the per-variant arms
produce `&NumericIndexInner<T>`, `&MapIndex<K>`, `&GeoMapIndex`, etc.
— different types. A unifying borrowed-enum (à la FacetIndexEnum)
would be more code than the trait-object indirection saves.

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

* refactor(field_index): migrate GeoMapIndex into condition_checker (#8979)

* refactor(field_index): migrate GeoMapIndex condition checking into condition_checker

Sub-plan PR 1 of the condition-checker-migration. GeoMapIndex now
serves geo conditions (geo_radius, geo_bounding_box, geo_polygon)
directly through PayloadFieldIndexRead::condition_checker. The
corresponding match arms and three helper functions in the read
view's helpers.rs are gone — the polymorphic dispatch in
field_condition_index handles them.

Changes:

1. impl PayloadFieldIndexRead for GeoMapIndex gains a condition_checker
   override. Bodies copied from get_geo_radius_checkers /
   get_geo_bounding_box_checkers / get_geo_polygon_checkers; the
   `&'a self` capture replaces the &FieldIndex match arm.

2. The override destructures FieldCondition explicitly (no `..`,
   every field named with either a binding or `_:`). This forces a
   compile error if a new field is added to FieldCondition, so each
   index variant must explicitly decide whether to handle it. Same
   pattern is mandated for the remaining variant migrations — see
   docs/plans/field-index-read-trait/condition-checker-migration/00-overview.md.

3. read_view/condition_converter/helpers.rs drops the three Geo
   FieldCondition arms from field_condition_index's legacy match
   and deletes the three helper functions. The catch-all is relaxed
   to `geo_radius: _ | geo_bounding_box: _ | geo_polygon: _` since
   the trait method handles all geo cases now.

No behavioural change: non-Geo variants continue to return None for
geo conditions (the trait default returns None), and the read view's
catch-all still falls back to the payload check.

Stacked on #8978 (condition-checker-trait foundation).

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

* refactor(field_index): migrate NullIndex into condition_checker (#8980)

* refactor(field_index): migrate NullIndex condition checking into condition_checker

Sub-plan PR 2 of the condition-checker-migration. NullIndex now
serves is_empty / is_null conditions directly through
PayloadFieldIndexRead::condition_checker. The dispatch in the read
view's condition_converter/mod.rs collapses to mirror the
Condition::Field arm: try every index for the field, fall back to
the payload check on unwrap_or_else.

Changes:

1. impl PayloadFieldIndexRead for NullIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) — binds
   is_empty and is_null, every other field uses `_:` to document
   intentional non-handling.

2. read_view/condition_converter/helpers.rs drops the is_empty /
   is_null arms from field_condition_index's legacy match and deletes
   five orphaned helpers: get_is_empty_checker, get_is_null_checker,
   get_is_empty_indexes, get_null_index_is_empty_checker,
   get_fallback_is_empty_checker.

3. read_view/condition_converter/mod.rs rewrites Condition::IsEmpty
   and Condition::IsNull to use field_condition_index with a
   constructed FieldCondition, same shape as Condition::Field.

Behavioural note (decision locked during review): The legacy
values_is_empty fast-path for "field has indexes but no NullIndex"
is dropped. NullIndex was introduced in v1.13.5 (#6088); we're on
v1.18.0, so any collection touched in the past ~5 minor releases has
a NullIndex. Segments untouched since pre-v1.13.5 fall through to the
payload check on is_empty queries — no longer accelerated by another
index's values_is_empty. A re-index recovers the original perf.

Stacked on #8979 (GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate NumericIndex into condition_checker (#8981)

* refactor(field_index): migrate NumericIndex condition checking into condition_checker

Sub-plan PR 3 of the condition-checker-migration. NumericIndexInner<T>
now serves Range conditions directly through
PayloadFieldIndexRead::condition_checker. The generic impl handles all
four FieldIndex variants (IntIndex, FloatIndex, DatetimeIndex,
UuidIndex) with one trait override.

Changes:

1. impl PayloadFieldIndexRead for NumericIndexInner<T> gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) binds `range`. Body converts the RangeInterface bounds
   into T via T::from_f64 / T::from_u128 — same conversion `filter`
   already uses.

2. read_view/condition_converter/helpers.rs drops the range arm from
   field_condition_index's legacy match and deletes
   get_range_checkers / get_float_range_checkers /
   get_datetime_range_checkers (3 helpers, ~75 lines). Six unused
   imports go with them.

Behavioural note: The legacy helpers were stricter than `filter` —
only IntIndex/FloatIndex served Float ranges, only DatetimeIndex
served DateTime ranges; UuidIndex returned None. `filter` already
handles every numeric variant uniformly via T::from_f64 / T::from_u128,
so there was a pre-existing inconsistency between filter (primary-
clause iteration) and condition_checker (post-filter validation).
This PR makes condition_checker match filter — every NumericIndex
variant can now serve any RangeInterface. The schema layer normally
prevents cross-type range queries from reaching here.

Stacked on #8980 (NullIndex) → #8979 (GeoMapIndex) → #8978
(foundation) → dev.

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

* refactor(field_index): migrate MapIndex into condition_checker (#8982)

* refactor(field_index): migrate MapIndex condition checking into condition_checker

Sub-plan PR 4 of the condition-checker-migration. MapIndex<K> now
serves Match::Value / Match::Any / Match::Except conditions directly
through PayloadFieldIndexRead::condition_checker, one override per K
(MapIndex<str>, MapIndex<UuidIntType>, MapIndex<IntPayloadType>).

Changes:

1. Three impl blocks gain condition_checker overrides — one per K.
   Each uses an explicit FieldCondition destructure (no `..`) and an
   exhaustive `Match` variant match (no `_ => None`); a new variant
   in FieldCondition, Match, ValueVariants, or AnyVariants forces a
   compile error in every relevant place. INDEXSET_ITER_THRESHOLD
   small/large branching preserved.

2. read_view/condition_converter/match_converter.rs sheds the Map
   arms. get_match_value_checker keeps (Bool, BoolIndex) plus the
   explicit 30-tuple None list. get_match_any_checker becomes an
   explicit 22-tuple None match (no Bool/FullText/Numeric/Geo/Null
   variant ever served Any). get_match_except_checker reduces to the
   unconditional values_count > 0 fallback — when no typed index
   handles Except (via condition_checker), match any point with at
   least one value, since the value can't be in a type-mismatched
   list. Unused IndexSet/Uuid/INDEXSET_ITER_THRESHOLD imports drop.

Stacked on #8981 (NumericIndex) → #8980 (NullIndex) → #8979
(GeoMapIndex) → #8978 (foundation) → dev.

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

* refactor(field_index): migrate BoolIndex into condition_checker (#8983)

* refactor(field_index): migrate BoolIndex condition checking into condition_checker

Sub-plan PR 5 of the condition-checker-migration. BoolIndex now
serves `Match::Value(Bool)` directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for BoolIndex gains a condition_checker
   override. Explicit FieldCondition destructure (no `..`) plus an
   exhaustive `Match` variant match (no `_ => None`). Match::Any /
   Match::Except over booleans return None — matches legacy
   match_converter behaviour.

2. read_view/condition_converter/match_converter.rs's
   get_match_value_checker drops the `(Bool, BoolIndex)` arm; the
   function now returns None unconditionally for every (value, index)
   pair, with the explicit 33-tuple list preserved so adding a new
   ValueVariants or FieldIndex variant forces a compile error.

Stacked on #8982 (MapIndex) → #8981 → #8980 → #8979 → #8978 → dev.

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

* refactor(field_index): migrate FullTextIndex into condition_checker (#8984)

* refactor(field_index): migrate FullTextIndex condition checking into condition_checker

Sub-plan PR 6 of the condition-checker-migration. FullTextIndex now
serves Match::Text / Match::TextAny / Match::Phrase directly through
PayloadFieldIndexRead::condition_checker.

Changes:

1. impl PayloadFieldIndexRead for FullTextIndex gains a
   condition_checker override. Explicit FieldCondition destructure
   (no `..`) plus exhaustive Match variant matching (no `_ => None`).
   Match::Value / Match::Any / Match::Except all return None
   explicitly. Body copies parse_text_query / parse_phrase_query /
   parse_text_any_query dispatch and the check_match closure from the
   legacy helper, preserving the FIXME-marked error swallowing.

2. read_view/condition_converter/match_converter.rs loses
   get_match_text_checker and the TextQueryType enum (both
   unused after this PR). get_match_checkers' Text/TextAny/Phrase
   arms collapse to a single explicit `None` arm.

Stacked on #8983 (BoolIndex) → #8982 (MapIndex) → #8981 → #8980 →

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

* refactor(field_index): remove legacy condition_checker dispatch helpers (#8985)

* refactor(field_index): remove legacy condition_checker dispatch helpers

Final PR (7) of the condition-checker-migration sub-plan. With every
typed FieldIndex variant now serving its conditions via
PayloadFieldIndexRead::condition_checker (PRs 1-6), the wrapper
`field_condition_index` and the legacy match dispatch are no longer
needed.

Changes:

1. read_view/condition_converter/mod.rs's three call sites
   (Condition::Field, Condition::IsEmpty, Condition::IsNull) call
   `index.condition_checker(...)` directly instead of going through
   the `field_condition_index` wrapper.

2. helpers.rs (49 lines) and match_converter.rs (119 lines) deleted —
   `field_condition_index`, `get_match_checkers`,
   `get_match_value_checker`, `get_match_any_checker`,
   `get_match_except_checker` are all gone.

3. The directory `condition_converter/` collapses to a flat file
   `condition_converter.rs` (mod.rs renamed via git).

Behavioural note: the legacy `Match::Except` `values_count > 0`
fallback for type-mismatched Except queries is no longer applied —
those now fall through to the payload check via
`check_field_condition`. Schema-level type checking prevents
cross-type Match::Except queries from reaching here in practice, so
the fallback was only useful for degenerate inputs; payload check is
semantically equivalent.

Audit grep on `lib/segment/src/`:

  $ grep -rn "field_condition_index\|get_match_checkers\|...\|TextQueryType"
  (no matches)

All legacy helper machinery is gone.

Stacked on #8984 (FullTextIndex) → #8983 → #8982 → #8981 → #8980 →

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

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead (#8986)

* refactor(field_index): migrate indexed_variable_retriever into FieldIndexRead

Follow-up to the condition-checker-migration sub-plan. The read view's
`value_retriever/helpers.rs` previously destructured `FieldIndex`
variants inside `indexed_variable_retriever` to build per-point value
extractors. This PR turns that into a `value_retriever` trait method
on `FieldIndexRead`, so the helper now depends only on the trait —
no variant destructuring outside `FieldIndex`'s own impl.

Changes:

1. FieldIndexRead gains `value_retriever(&self, hw_counter)`. Lives
   on the enum-level trait (rather than `PayloadFieldIndexRead`)
   because the value→Value conversion depends on the payload type
   `U` in `NumericIndex<T, U>`, and only `FieldIndex` knows the
   `(T, U)` pairing.

2. impl FieldIndexRead for FieldIndex implements value_retriever
   with an 11-arm variant match. Bodies copied verbatim from the old
   `indexed_variable_retriever`. FullTextIndex and NullIndex return
   None (caller falls back to payload).

3. read_view/value_retriever/helpers.rs:
   - `variable_retriever` now calls `index.value_retriever(hw_counter)`
     directly via trait dispatch
   - `indexed_variable_retriever` deleted
   - Unused imports dropped (Number, DateTimePayloadType,
     UuidPayloadType, MultiValue)

Helpers.rs shrinks from 189 lines to 73 lines (the test module
stays). Total: +134 / -122 across 3 files, but the structural change
is moving the dispatch into the trait.

Stacked on #8985 (condition-checker-cleanup) → #8984 → … → #8978 → dev.

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

* refactor(field_index): push value_retriever conversion logic into typed indexes

`FieldIndex::value_retriever` previously inlined the per-variant
value→JSON `Value` conversion (Number, String, DateTime, UUID, Bool,
serde_json::to_value for geo) as a 100-line variant match. Move each
variant's conversion into an inherent `value_retriever` method on the
corresponding typed index; `FieldIndex` is left with a thin
11-arm dispatch that just delegates.

Changes:

1. NumericIndex<T, U> gains 4 per-(T, U) inherent value_retriever
   impls (Int/Datetime/Float/Uuid). The conversion is U-specific
   (timestamp formatting, UUID string, Number::from_f64 etc.), so
   each (T, U) pair has its own impl block.

2. MapIndex<K> gains 3 per-K inherent value_retriever impls
   (Keyword/Int/Uuid).

3. GeoMapIndex and BoolIndex each gain a single inherent
   value_retriever.

4. FieldIndex::value_retriever collapses to a 11-arm match that
   delegates to the typed index's inherent method. FullTextIndex
   and NullIndex still return None at the FieldIndex level — they
   don't expose value retrieval and the caller falls back to payload.

5. field_index.rs sheds the Number, MultiValue and Box::new
   noise — about 100 lines smaller.

Same shape as how `wipe`, `add_point`, `get_telemetry_data` already
delegate from FieldIndex to typed indexes. Adding a new FieldIndex
variant now forces compile errors in (a) the dispatch in FieldIndex
and (b) the new typed index's inherent impl — both correct places.

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

* refactor(field_index): push BoolIndex/NullIndex condition_checker into storage variants

The `BoolIndex` and `NullIndex` wrappers were special-cased among
typed indexes: their `PayloadFieldIndexRead::condition_checker`
impls did the variant-specific work directly on `self` (matching
`Match::Value(Bool)`, `is_empty`, `is_null`) and called
`self.check_values_any` / `self.values_is_empty` / `self.values_is_null`,
each of which dispatched `match self { Mmap(...) | Immutable(...) }`
per point. The inner storage variants (`Immutable/MutableBoolIndex`,
`Immutable/MutableNullIndex`) implemented `PayloadFieldIndexRead`
solely for `filter` / `count_indexed_points` / `estimate_cardinality`
/ `for_each_payload_block` — their `condition_checker` was unreachable
behind the trait's default `None` body.

Removing the trait default surfaced this asymmetry. Rather than stub
the inner-type `condition_checker` as dead `None`, push the real
logic down to where the storage variants live — same shape as
`filter` already uses:

  inner: explicit FieldCondition destructure + exhaustive Match
         arms; per-point closure captures `&'a self` of the inner
         type directly.
  outer: 2-arm `match self { ... => inner.condition_checker(...) }`.

Result: per-point closure body no longer hits a `match self { ... }`
on the wrapper. The wrapper dispatch happens once during setup when
the wrapper picks which inner closure to return. Matches the pattern
the other 5 trait methods (filter/count/estimate/for_each_block) on
these wrappers already use.

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

* CI fix

* upd docstring

---------

Co-authored-by: Claude Opus 4.7 (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