-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TimeSeries Desc Sort gets skipped with Lucene 10 upgrade #17329
base: main
Are you sure you want to change the base?
Conversation
…IdxSearcher Signed-off-by: expani <[email protected]>
Signed-off-by: expani <[email protected]>
This is explains the |
@reta With this change, OS 2.19 and OS 3.0 are at same for following query types in big5
Without it, the latency for OS 3.0 was 10ms more than OS 2.19 |
❌ Gradle check result for 21d5903: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
❌ Gradle check result for 368383f: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: expani <[email protected]>
// TODO : Remove when switching to use the @org.apache.lucene.search.IndexSearcher#search(Query, CollectorManager) variant from | ||
// @org.opensearch.search.query.QueryPhase#searchWithCollector which then calls the overridden | ||
// search(LeafReaderContextPartition[] partitions, Weight weight, Collector collector) | ||
query = collector.scoreMode().needsScores() ? rewrite(query) : rewrite(new ConstantScoreQuery(query)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@msfroh this change make sense to me to restore searchContext.shouldUseTimeSeriesDescSortOptimization()
optimization, wdyt?
❌ Gradle check result for 21a924d: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
query = collector.scoreMode().needsScores() ? rewrite(query) : rewrite(new ConstantScoreQuery(query)); | ||
Weight weight = createWeight(query, collector.scoreMode(), 1); | ||
LeafSlice[] leafSlices = getSlices(); | ||
for (LeafSlice leafSlice : leafSlices) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@expani I think we should get all partitions across all slices and call search
only once:
LeafReaderContextPartition[] partitions = Arrays.stream(getSlices()).flatMap(LeafSlice::partitions).toArray();
search(partitions, weight, collector)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can override the logic in getSlices, we could even handle the desc sort use-case more efficiently by returning slices that contain leafcontextpartitions with the higher doc ids and front-load those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Lucene 10.1.0 and OS 3.0 call flow
With Lucene 10 changes, the new replacement method
only gets invoked via
IndexSearcher#search(Query, CollecterManager)
which is not used by OpenSearch inQueryPhase#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
Resolves #16934