Skip to content

feat(python): expose the distance_range param in the Python scanner nearest config#5486

Merged
wjones127 merged 2 commits intolance-format:mainfrom
xloya:expose-nearest-distance-range-in-python
Jan 2, 2026
Merged

feat(python): expose the distance_range param in the Python scanner nearest config#5486
wjones127 merged 2 commits intolance-format:mainfrom
xloya:expose-nearest-distance-range-in-python

Conversation

@xloya
Copy link
Copy Markdown
Contributor

@xloya xloya commented Dec 16, 2025

Rust core now supports limiting the distance range during vector searches. This parameter can be exposed in the Python SDK so that users can limit the distance range of the returned results when performing vector queries.

User could use this to do a vector distance range search:

import lance

ds = lance.dataset("vec_test.lance")
q = ds.sample(1).column("vec").to_pylist()[0]
distance_range = (0.0, 1.0)
results = ds.to_table(
    columns=["id"],
    nearest={
        "column": "vector",
        "q": q,
        "k": 20,
        "distance_range": distance_range,
    },
)

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions github-actions Bot added enhancement New feature or request python labels Dec 16, 2025
@github-actions
Copy link
Copy Markdown
Contributor

ACTION NEEDED
Lance follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

For details on the error please inspect the "PR Title Check" action.

@xloya xloya changed the title feat: expose the distance_range param in the Python scanner nearest configuration for vector search feat: expose the distance_range param in the Python scanner nearest config Dec 16, 2025
@wjones127 wjones127 changed the title feat: expose the distance_range param in the Python scanner nearest config feat(python): expose the distance_range param in the Python scanner nearest config Jan 1, 2026
Copy link
Copy Markdown
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@wjones127 wjones127 merged commit 3a54c63 into lance-format:main Jan 2, 2026
12 checks passed
jackye1995 pushed a commit to jackye1995/lance that referenced this pull request Jan 21, 2026
… `nearest` config (lance-format#5486)

Rust core now supports limiting the distance range during vector
searches. This parameter can be exposed in the Python SDK so that users
can limit the distance range of the returned results when performing
vector queries.

User could use this to do a vector distance range search:
```python
import lance

ds = lance.dataset("vec_test.lance")
q = ds.sample(1).column("vec").to_pylist()[0]
distance_range = (0.0, 1.0)
results = ds.to_table(
    columns=["id"],
    nearest={
        "column": "vector",
        "q": q,
        "k": 20,
        "distance_range": distance_range,
    },
)

```

Co-authored-by: xloya <xiaojiebao@apache.org>
Co-authored-by: Will Jones <willjones127@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants