Skip to content

feat: support inclusive numeric ranges in Lucene filters and field groups#976

Open
kaya-david wants to merge 8 commits into
mainfrom
dev-lucene-range-expression
Open

feat: support inclusive numeric ranges in Lucene filters and field groups#976
kaya-david wants to merge 8 commits into
mainfrom
dev-lucene-range-expression

Conversation

@kaya-david

@kaya-david kaya-david commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Description

  • add support for inclusive numeric Lucene range expressions using square brackets, such as age:[18 TO 65].
  • support integer and floating-point ranges for both regular search fields and field group syntax.
  • support negative range boundaries by normalizing Luqum's Prohibit nodes.
  • reject exclusive ranges, non-numeric or non-finite boundaries, and reversed ranges with descriptive errors.
  • add parametrized tests covering valid ranges, boundary values, invalid expressions, and both supported syntax variants.

Assignee

  • The changes adhere to the contribution guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings (e.g. flake8/mypy/pytest/...) other than deprecations

Documentation

Code Quality

  • Patch test coverage > 95% and does not decrease
  • New code uses correct & specific type hints

How did you verify that the changes work in practice?

  • pytest

Reviewer


The rendered docs for this PR can be found here.

@kaya-david kaya-david self-assigned this Jun 18, 2026
@kaya-david kaya-david marked this pull request as ready for review June 18, 2026 13:16
@kaya-david kaya-david requested a review from Pablu23 June 18, 2026 13:16
@kaya-david kaya-david force-pushed the dev-lucene-range-expression branch from 10331bf to 6f1c006 Compare June 19, 2026 09:33

@Pablu23 Pablu23 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good so far, had a few questions and notes

Comment thread logprep/filter/lucene_filter.py Outdated
Comment thread logprep/filter/lucene_filter.py
Comment thread logprep/filter/lucene_filter.py Outdated
Comment on lines +338 to +345
expression = str(expr)
lower_token, upper_token = expr.children

if not expression.startswith("[") or not expression.endswith("]"):
raise LuceneFilterError(
f'The expression "{expression}" is invalid. '
"Only inclusive ranges using square brackets are supported."
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This seems, overengineered, does expression not expose this in a nicer way?

Comment thread logprep/filter/lucene_filter.py Outdated
lower_bound_float = float(lower_value)
upper_bound_float = float(upper_value)
except ValueError as error:
raise LuceneFilterError(f'The expression "{expression}" is invalid!') from error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We do want string ranges, so timestamps of ISO 8601 Format, are possible

Comment thread CHANGELOG.md Outdated
@kaya-david kaya-david requested a review from Pablu23 June 23, 2026 08:27
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