-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Omit maxScoreCollector for field collapsing when sort by score descending #19181
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
base: main
Are you sure you want to change the base?
Omit maxScoreCollector for field collapsing when sort by score descending #19181
Conversation
…ding Signed-off-by: Binlong Gao <[email protected]>
Signed-off-by: Binlong Gao <[email protected]>
Signed-off-by: Binlong Gao <[email protected]>
❌ Gradle check result for 23018ff: 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 23018ff: UNSTABLE Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #19181 +/- ##
============================================
- Coverage 72.87% 72.80% -0.08%
+ Complexity 69645 69608 -37
============================================
Files 5656 5656
Lines 319999 320010 +11
Branches 46335 46338 +3
============================================
- Hits 233191 232968 -223
- Misses 67907 68134 +227
- Partials 18901 18908 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
MaxScoreCollector maxScoreCollector = null; | ||
if (trackMaxScore) { | ||
final MaxScoreCollector maxScoreCollector; | ||
if (sortByScore) { |
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.
I’m curious why we don’t retrieve it from the maxScoreCollector
(as shown in line 271), and instead need to get the maximum score from topDocs.scoreDocs[0]?
Description
Similar to SimpleTopDocsCollectorContext, we can omit the MaxScoreCollector when sorting by score in CollapsingTopDocsCollectorContext, this can reduce the search latency and cpu usage.
By a benchmark test against the big5 index and other indices, this change can achieve 10%-20% performance improvement in both concurrent segment search enabled and disabled.
The query DSL on big5 index is:
, the benchmark result:
In addition, this PR fixes the bug that max_score is null when we have multiple sort fields and _score is used as a primary sort.
Related Issues
Resolves #19179 and partly resolves #19180.
Check List
- [ ] API changes companion pull request created, if applicable.
- [ ] Public documentation issue/PR created, if applicable.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.