Skip to content

Support chaining FindQuery filters - #844

Open
lh0156 wants to merge 3 commits into
redis:mainfrom
lh0156:agent/find-query-chain-780
Open

Support chaining FindQuery filters#844
lh0156 wants to merge 3 commits into
redis:mainfrom
lh0156:agent/find-query-chain-780

Conversation

@lh0156

@lh0156 lh0156 commented Jul 26, 2026

Copy link
Copy Markdown

Summary

Implements #780 by allowing FindQuery instances to accept additional filter expressions through .find().

What changed

  • Adds FindQuery.find(*expressions) and returns a new query, leaving the original unchanged.
  • Appends expressions to the existing query so they use the same AND semantics as Model.find(expr1, expr2).
  • Preserves the query's KNN state when creating the chained query.
  • Documents incremental filter construction.

Testing

  • pytest -q tests/test_find_query.py tests_sync/test_find_query.py: 52 passed.
  • pytest -q tests --ignore tests/test_benchmarks.py: 261 passed.
  • pytest -q tests_sync --ignore tests_sync/test_benchmarks.py: 261 passed.
  • ruff check and ruff format --check on changed source/tests.
  • python -m compileall -q aredis_om tests.
  • bandit -q -r aredis_om/model/model.py -s B608.

Redis Stack was run locally through Docker Compose for the integration tests; benchmark tests were excluded from the full run.


Note

Low Risk
Small, additive query API on top of existing FindQuery.copy() behavior; covered by find-query tests with no auth or data-migration impact.

Overview
FindQuery now supports chaining filters via a new .find(*expressions) method, so you can build queries step by step instead of passing every predicate into Model.find() up front.

Each call returns a new FindQuery (via copy()), appending expressions with the same AND semantics as Model.find(expr1, expr2), and preserves KNN state on the chained query. Documentation in querying.md shows incremental construction; an async integration test verifies chaining, sorting, and that the original query object is unchanged.

Reviewed by Cursor Bugbot for commit 1e0cac1. Bugbot is set up for automated code reviews on this repo. Configure here.

@abrookins

Copy link
Copy Markdown
Collaborator

@lh0156 This sounds great! I'll take a look ASAP.

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.

2 participants