Skip to content

Conversation

@iverase
Copy link
Contributor

@iverase iverase commented Dec 2, 2025

This is a fix for a performance bug reported in this discuss issue.

In lucene 10.3 there was this change to speed up must not queries. The change has the side effect that we might be calling LeafCollector#setScorer many more times than before. This is probably ok because it is expected to be a cheap method.

TopHitsAggregator contains an implementation of LeafCollector#setScorer that can be expensive if the aggregator is part of a multi-bucket aggregator. Whenever we set the scorer we are looping over all buckets to set the scorer.

Therefore, this commit proposes to introduce a wrapper for the Scorable that is shared by all the buckets so we only need to change it in one place when present.

@elasticsearchmachine elasticsearchmachine added v9.2.3 Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch and removed branch:9.2 labels Dec 2, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@elasticsearchmachine
Copy link
Collaborator

Hi @iverase, I've created a changelog YAML for you.

@iverase iverase added the auto-backport Automatically create backport pull requests when merged label Dec 2, 2025
@iverase iverase merged commit c95dcea into elastic:main Dec 2, 2025
34 checks passed
@iverase iverase deleted the topHitsScorer branch December 2, 2025 13:03
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.2

iverase added a commit to iverase/elasticsearch that referenced this pull request Dec 2, 2025
this commit introduce a wrapper for the Scorable that is shared by all the buckets so we only need to change it 
in one place when present.
elasticsearchmachine pushed a commit that referenced this pull request Dec 2, 2025
)

this commit introduce a wrapper for the Scorable that is shared by all the buckets so we only need to change it 
in one place when present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged >bug :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.2.3 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants