Skip to content

BooleanQuery: narrow bulk scoring when FILTER matches primary index sort#15991

Open
iprithv wants to merge 6 commits intoapache:mainfrom
iprithv:opt-primary-sort-filter
Open

BooleanQuery: narrow bulk scoring when FILTER matches primary index sort#15991
iprithv wants to merge 6 commits intoapache:mainfrom
iprithv:opt-primary-sort-filter

Conversation

@iprithv
Copy link
Copy Markdown
Contributor

@iprithv iprithv commented Apr 28, 2026

Description

Implements #15139 : When a BooleanQuery has a FILTER clause that constrains the primary index sort field, rewrite to an internal query that can restrict the main clause's BulkScorer to a contiguous doc ID range derived from the filter, when it is safe to do so.

The optimization currently applies to:

  • sorted numeric range filters on the primary index sort field
  • exact term filters on a primary SortedSetSortField when doc values and postings agree on a dense range

If the range cannot be proven safe for a leaf, execution falls back to the original boolean query's bulk scorer for that leaf.

Benchmarking

Focused JMH benchmark: PrimaryIndexSortFilterBenchmark

Benchmark Baseline (origin/main) Candidate Delta
benchmarkSortedTopScores 1.315 ± 0.013 ops/ms 2.286 ± 0.032 ops/ms ~+74%
benchmarkSortedComplete 1.491 ± 0.020 ops/ms 2.145 ± 0.137 ops/ms ~+44%
benchmarkSortedCompleteNoScores 3.249 ± 0.027 ops/ms 4.774 ± 0.035 ops/ms ~+47%
benchmarkUnsortedTopScores 1.306 ± 0.014 ops/ms 1.334 ± 0.009 ops/ms ~+2%

These numbers compare origin/main with the same benchmark class copied in against this branch, using the benchmark's full JMH annotations.

Signed-off-by: prithvi <[email protected]>
@github-actions github-actions Bot added this to the 11.0.0 milestone Apr 28, 2026
Signed-off-by: prithvi <[email protected]>
@iprithv iprithv force-pushed the opt-primary-sort-filter branch from fe1fe81 to 9df46b8 Compare April 28, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant