Skip to content

feat(query): add FilterExpression.not() operator#30

Closed
ajGingrich wants to merge 3 commits into
mainfrom
feat/filter-expression-not
Closed

feat(query): add FilterExpression.not() operator#30
ajGingrich wants to merge 3 commits into
mainfrom
feat/filter-expression-not

Conversation

@ajGingrich
Copy link
Copy Markdown
Collaborator

Closes #18

Summary

  • Adds FilterExpression.not() mirroring Python redisvl's ~filter negation, wrapping an expression in -(...).
  • Negating the wildcard * collapses to * (negating "match everything" is a no-op).
  • Updates filters-and-queries.md with .not() examples alongside .and() / .or().

Test plan

  • Unit tests for negation alone, double-negation, negation of wildcard, and combinations with .and() / .or() and nested expressions
  • npm test -- --run tests/unit → 429 passing (up from 421)
  • npm run lint clean, npm run format:check clean

🤖 Generated with Claude Code

ajGingrich and others added 2 commits May 18, 2026 11:27
Closes #18

Mirrors Python redisvl's ~filter negation. .not() wraps an expression
in -(...), and negating the wildcard '*' collapses to '*' (negating
"match everything" is a no-op).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 18, 2026 17:32
Copy link
Copy Markdown

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

Adds unary negation support to the query filter DSL via FilterExpression.not(), matching the requested -(...) rendering and wildcard-collapse behavior.

Changes:

  • Adds NOT handling and .not() to FilterExpression.
  • Adds unit coverage for simple, wildcard, double, composed, and nested negation.
  • Updates filter/query docs and ignores local .worktrees/.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/query/filter.ts Implements FilterExpression.not() rendering and validation.
tests/unit/query/filter.test.ts Adds unit tests for negation behavior and composition.
website/docs/user-guide/filters-and-queries.md Documents .not() usage in filter composition examples.
.gitignore Adds .worktrees/ to ignored local files.

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

Comment thread website/docs/user-guide/filters-and-queries.md
Addresses Copilot review feedback on #30. The snippet uses
FilterExpression for the wildcard collapse examples; add it to the
import so the example is copy-pasteable.

PR-Shepherd: true
PR-Shepherd-Mode: manual

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

Add FilterExpression.not() operator

2 participants