Skip to content

[BUG] Time Series Desc Optimisation gets skipped with Lucene 10 Upgrade #17386

@expani

Description

@expani

Describe the bug

Description

We override IndexSearcher#search(List<LeafReaderContext> leaves, Weight weight, Collector collector) and it contains the logic to apply time series desc optimisation for scanning segments in reverse for descending sort use-cases.

Existing Lucene 9.12.1 and OS 2.19 call flow

Screenshot 2025-02-11 at 2 40 05 PM

Lucene 10.1.0 and OS 3.0 call flow

Screenshot 2025-02-11 at 2 40 52 PM

With Lucene 10 changes, the new replacement method

search(LeafReaderContextPartition[] partitions, Weight weight, Collector collector)

only gets invoked via IndexSearcher#search(Query, CollecterManager) which is not used by OpenSearch in QueryPhase#searchWithCollector.

So, it was never getting called causing the time series desc optimization to be skipped.

My changes ensure it will be called in the same way that IndexSearcher does for CollectorManager variant.

Related Issues

PR for the fix #17329

Related component

Search:Performance

To Reproduce

Execute asc_sort_timestamp and compare the latency it will be slower with OS 3.0 compared to OS 2.19

Expected behavior

Time Series Desc Optimisation should be invoked for sort queries.

Additional Details

Meta

Metadata

Metadata

Assignees

Type

No type

Projects

Status

✅ Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions