Skip to content

[docs](lance) Document radius and range vector search - #4200

Merged
Gabriel39 merged 2 commits into
apache:masterfrom
Gabriel39:dev/lance-distance-range-docs
Oct 10, 2026
Merged

Gabriel39 merged 2 commits into
apache:masterfrom
Gabriel39:dev/lance-distance-range-docs

Conversation

@Gabriel39

@Gabriel39 Gabriel39 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Companion to apache/doris#68815. Merge the documentation with the implementation.

Document distance_lower_bound and distance_upper_bound in the English and Chinese 4.x Lance Catalog guides, including FLOAT and squared-L2 semantics, expected results, filtering and offset order, Top-K limits, and prepared-statement bound parameters.

Explain that only two-sided ranges on explicitly identified IVF_FLAT indexes use indexed search. Single-sided ranges and quantized or unknown index types fall back to exact Flat Search, with DISTANCE_RANGE_FALLBACK in EXPLAIN and potentially higher scan cost. Remove the schema-version upgrade requirement; the implementation retains the existing protocol version.

Validation: the modified range sections compile as MDX in both locales, and git diff --check passes. A full website build was not run.

yiguolei pushed a commit to apache/doris that referenced this pull request Oct 10, 2026
### What problem does this PR solve?

Issue Number: Closes #66493

`vector_search()` cannot currently restrict results by distance. This
adds optional `distance_lower_bound` (inclusive) and
`distance_upper_bound` (exclusive) parameters for single-vector
Radius/Range Search on Lance tables.

The FE validates finite FLOAT bounds and their order, includes the range
in EXPLAIN, and carries it through the external-search request. The BE
applies the bounds through the existing pinned lance-c API after
configuring the query vector, covering indexed and Flat Search splits,
including appended data outside index coverage. The existing
external-search schema version remains unchanged at 1.

Results retain the existing table columns and FLOAT `_distance`,
prefilter semantics, offset, and Top-K cap. Bounds can be bound through
prepared-statement parameters and are revalidated on each execution.
Multi-vector distance bounds are rejected.

Bounded index search is limited to explicitly identified IVF_FLAT
segments with both bounds present. Quantized or unknown index types and
single-sided ranges fall back to exact fragment scans, reported as
`DISTANCE_RANGE_FALLBACK` in EXPLAIN. This avoids pre-refinement
quantization errors and the pinned index implementation’s finite
sentinels for absent bounds, at the cost of additional scanning.
Unbounded queries retain their index selection; indexed IVF_FLAT recall
still depends on probed partitions.

Standalone BM25 is already delivered; the distributed BM25 statistics
follow-up remains tracked separately in #67435.

### Release note

Lance `vector_search()` supports optional lower and upper distance
bounds for single-vector radius and range queries.

### Validation

- BE: rebuilt the current branch and passed all 68 `LanceTableReader*`
tests under ASAN, including exact SQ threshold crossing, the finite
FLT_MAX DOT endpoint, prefilter variants, and existing reader coverage.
- FE: 76 tests passed across `VectorSearchTableValuedFunctionTest`,
`LancePreparedSearchTest`, `LancePreparedStatementTest`, and
`LanceScanNodeTest`, including repeated bound binding, invalid
parameters, all index subtypes, and indexed/flat split selection.
- Native reproduction: the pinned indexed paths drop both the SQ
threshold-crossing row and the finite FLT_MAX DOT endpoint; exact Flat
Search returns both. Added self-contained fixtures and reader coverage
for these cases.
- Native execution: 10 cases passed against the pinned lance-c revision,
covering indexed/Flat Search, appended unindexed data,
inclusive/exclusive bounds, empty results, prefiltering, and offset.
- FE Checkstyle and clang-format 16 checks passed.
- Added SQL regression coverage for range results, projected stored
columns, filtering, offset, invalid bounds, and EXPLAIN. Its Groovy
syntax compilation passed; the SQL suite has not yet run against a live
Doris cluster and requires External Regression CI.

### Check List (For Author)

- Test
  - [x] Regression test added (execution pending CI)
  - [x] Unit Test
  - [x] Manual native execution test
- Behavior changed:
- [x] Yes: optional distance bounds on single-vector searches; existing
unbounded queries retain their behavior.
- Does this need documentation?
- [x] Yes: bilingual 4.x Lance Catalog documentation:
apache/doris-website#4200.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
@Gabriel39
Gabriel39 merged commit bd9be58 into apache:master Oct 10, 2026
3 checks passed
yiguolei pushed a commit to apache/doris that referenced this pull request Oct 10, 2026
### What problem does this PR solve?

Issue Number: Closes #66493

`vector_search()` cannot currently restrict results by distance. This
adds optional `distance_lower_bound` (inclusive) and
`distance_upper_bound` (exclusive) parameters for single-vector
Radius/Range Search on Lance tables.

The FE validates finite FLOAT bounds and their order, includes the range
in EXPLAIN, and carries it through the external-search request. The BE
applies the bounds through the existing pinned lance-c API after
configuring the query vector, covering indexed and Flat Search splits,
including appended data outside index coverage. The existing
external-search schema version remains unchanged at 1.

Results retain the existing table columns and FLOAT `_distance`,
prefilter semantics, offset, and Top-K cap. Bounds can be bound through
prepared-statement parameters and are revalidated on each execution.
Multi-vector distance bounds are rejected.

Bounded index search is limited to explicitly identified IVF_FLAT
segments with both bounds present. Quantized or unknown index types and
single-sided ranges fall back to exact fragment scans, reported as
`DISTANCE_RANGE_FALLBACK` in EXPLAIN. This avoids pre-refinement
quantization errors and the pinned index implementation’s finite
sentinels for absent bounds, at the cost of additional scanning.
Unbounded queries retain their index selection; indexed IVF_FLAT recall
still depends on probed partitions.

Standalone BM25 is already delivered; the distributed BM25 statistics
follow-up remains tracked separately in #67435.

### Release note

Lance `vector_search()` supports optional lower and upper distance
bounds for single-vector radius and range queries.

### Validation

- BE: rebuilt the current branch and passed all 68 `LanceTableReader*`
tests under ASAN, including exact SQ threshold crossing, the finite
FLT_MAX DOT endpoint, prefilter variants, and existing reader coverage.
- FE: 76 tests passed across `VectorSearchTableValuedFunctionTest`,
`LancePreparedSearchTest`, `LancePreparedStatementTest`, and
`LanceScanNodeTest`, including repeated bound binding, invalid
parameters, all index subtypes, and indexed/flat split selection.
- Native reproduction: the pinned indexed paths drop both the SQ
threshold-crossing row and the finite FLT_MAX DOT endpoint; exact Flat
Search returns both. Added self-contained fixtures and reader coverage
for these cases.
- Native execution: 10 cases passed against the pinned lance-c revision,
covering indexed/Flat Search, appended unindexed data,
inclusive/exclusive bounds, empty results, prefiltering, and offset.
- FE Checkstyle and clang-format 16 checks passed.
- Added SQL regression coverage for range results, projected stored
columns, filtering, offset, invalid bounds, and EXPLAIN. Its Groovy
syntax compilation passed; the SQL suite has not yet run against a live
Doris cluster and requires External Regression CI.

### Check List (For Author)

- Test
  - [x] Regression test added (execution pending CI)
  - [x] Unit Test
  - [x] Manual native execution test
- Behavior changed:
- [x] Yes: optional distance bounds on single-vector searches; existing
unbounded queries retain their behavior.
- Does this need documentation?
- [x] Yes: bilingual 4.x Lance Catalog documentation:
apache/doris-website#4200.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label

This branch was previously deployed

1 inactive deployment
Production — c1d25a31 Deployed Oct 9, 2026 by Gabriel39 via Build Check #8468
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