Repository navigation
SOLR-18585: intervals script support - #5224
Conversation
|
Review TL/DR:
Review details: @mkhludnev I reviewed Two suggestions:
My recommendation is to correct the example here and consider reusing the adapters before merging. If retaining the current implementation keeps this change substantially simpler, a focused allocation benchmark would help decide whether the optimization belongs in a follow-up. Neither point calls for widening the script language or changing its semantics. Would you prefer to address the adapter setup in this PR, or assess its cost separately and keep this change focused on the initial functionality? |
|
@nick-boss-tech thanks for keen review. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The matches implementation can incorrectly report a named query as matching when its script rejects every interval.
1 open issue
What changed in this PR
Adds a script filter to Solr’s Intervals Query Parser, allowing Lucene Expressions to select intervals by their positions and gaps.
Changes:
- Implements script compilation, variable validation, and interval filtering.
- Adds unit and distributed tests for expressions and error handling.
- Documents the operator and records the feature in the changelog.
| File | Description |
|---|---|
| solr/solr-ref-guide/modules/query-guide/pages/intervals-query-parser.adoc | Documents script variables and usage examples. |
| solr/core/src/test/org/apache/solr/search/TestIntervalsQParserPlugin.java | Tests variable filtering and invalid expressions. |
| solr/core/src/test/org/apache/solr/search/DistributedQParserTest.java | Tests script filtering across shards. |
| solr/core/src/java/org/apache/solr/search/ScriptFilterIntervalsSource.java | Implements expression-based interval and match filtering. |
| solr/core/src/java/org/apache/solr/search/IntervalsQParserPlugin.java | Parses scripts and validates supported variables. |
| changelog/unreleased/intervals-script-filter.yml | Records the new script filter feature. |
Review effort: Balanced
Add logic to check for acceptance in ScriptFilterIntervalsSource. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Hi @mkhludnev, The current helper closes its DirectoryReader before callers consume the returned iterator. I changed it to borrow a LeafReaderContext; each test now owns its reader and keeps it open through all iterator assertions. Only TestScriptFilterIntervalsSource.java changes. Production code and the existing assertions are unchanged. I recommend including this small change so the tests use reader-backed postings only while the reader is open. Would you be comfortable incorporating it here? |
Solr 18585 submit
|
cherry=picked it, thanks @nick-boss-tech |


https://issues.apache.org/jira/browse/SOLR-18585
This pull request adds support for a new
scriptfilter operator to the Intervals Query Parser in Solr. This operator allows users to filter intervals using Lucene Expressions scripts, with access to interval-specific variables such asinterval.start,interval.end, andinterval.gap. The implementation includes backend support, comprehensive tests, and documentation updates.Intervals Query Parser Enhancements:
scriptfilter operator in the Intervals Query Parser, enabling interval filtering based on Lucene Expressions evaluated withinterval.start,interval.end, andinterval.gapvariables. [1] [2] [3]Testing:
scriptfilter operator, including handling of valid scripts, combined variable expressions, invalid scripts, and unknown variables. [1] [2]Documentation:
scriptfilter operator, its usage, and examples illustrating how to use interval variables in expressions. [1] [2] [3]Changelog:
Description
Please provide a short description of the changes you're making with this pull request.
Solution
Please provide a short description of the approach taken to implement your solution.
We appreciate transparent disclosure of significant AI Coding assistants usage.
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.