Skip to content

Comments

Expose max_distance as an optional setting in multi vector queries#478

Merged
justin-cechmanek merged 6 commits intomainfrom
feat/RAAE-1098/expose-max-distance
Feb 21, 2026
Merged

Expose max_distance as an optional setting in multi vector queries#478
justin-cechmanek merged 6 commits intomainfrom
feat/RAAE-1098/expose-max-distance

Conversation

@justin-cechmanek
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 19, 2026 22:35
@jit-ci
Copy link

jit-ci bot commented Feb 19, 2026

Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.

In case there are security findings, they will be communicated to you as a comment inside the PR.

Hope you’ll enjoy using Jit.

Questions? Comments? Want to learn more? Get in touch with us.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for configurable max_distance parameters in multi-vector queries, allowing users to specify different distance thresholds for each vector field. Previously, the max_distance was hardcoded to 2.0.

Changes:

  • Added max_distance field to the Vector class with default value of 2.0 and validation range [0.0, 2.0]
  • Modified MultiVectorQuery to use per-vector max_distance values in VECTOR_RANGE queries
  • Changed query operator from | (OR) to AND for combining multiple vector range queries
  • Added comprehensive unit and integration tests for the new max_distance functionality

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
redisvl/query/aggregate.py Added max_distance field to Vector class with validation; updated query building to use per-vector max_distance values; changed operator from OR to AND
tests/unit/test_aggregation_types.py Added test coverage for max_distance parameter including validation tests and query string generation tests
tests/integration/test_aggregation.py Added parameterized integration test to verify max_distance filtering behavior with various distance combinations
tests/integration/test_search_index.py Minor formatting: added blank line for code style consistency
tests/integration/test_redis_cluster_support.py Minor formatting: added blank lines for code style consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 19, 2026 23:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +44
if not isinstance(max_distance, (float, int)):
raise ValueError("max_distance must be a value between 0.0 and 2.0")
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The type check isinstance(max_distance, (float, int)) on line 43 is redundant because Pydantic's field validation already ensures the field is of type float. Additionally, this check will always pass since the field is declared as max_distance: float = 2.0. The more important validation is the range check on line 45, which should remain.

Suggested change
if not isinstance(max_distance, (float, int)):
raise ValueError("max_distance must be a value between 0.0 and 2.0")

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@nkanu17 nkanu17 left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Collaborator

@vishal-bala vishal-bala left a comment

Choose a reason for hiding this comment

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

LGTM! Just one note where you can use built-in Pydantic validation instead of custom

Co-authored-by: Vishal Bala <vishal-bala@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 21, 2026 01:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +47 to +54
@field_validator("max_distance")
@classmethod
def validate_max_distance(cls, max_distance: float) -> float:
if not isinstance(max_distance, (float, int)):
raise ValueError("max_distance must be a value between 0.0 and 2.0")
if max_distance < 0.0 or max_distance > 2.0:
raise ValueError("max_distance must be a value between 0.0 and 2.0")
return max_distance
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

validate_max_distance currently rejects infinities but will still allow NaN (all comparisons to NaN are false, so it passes through). NaN would produce an invalid VECTOR_RANGE radius in the query string. Consider explicitly rejecting non-finite values (and also disallowing bool, since it’s an int subclass).

Copilot uses AI. Check for mistakes.
Comment on lines +385 to +388
f"@{field}:[VECTOR_RANGE {max_dist} $vector_{i}]=>{{$YIELD_DISTANCE_AS: distance_{i}}}"
)

range_query = " | ".join(range_queries)
range_query = " AND ".join(range_queries)
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

This changes the multi-vector query from OR semantics (|) to AND semantics when combining vector range clauses. That’s a behavior change beyond “expose max_distance” and could be breaking for existing callers. If the AND behavior is intentional, it should be called out in the PR description/release notes (or consider preserving prior behavior via an option).

Copilot uses AI. Check for mistakes.
@justin-cechmanek justin-cechmanek merged commit 61f0f41 into main Feb 21, 2026
47 checks passed
@justin-cechmanek justin-cechmanek deleted the feat/RAAE-1098/expose-max-distance branch February 21, 2026 01:37
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.

3 participants