Skip to content

terminate_after is not honour when size = 0 and query has aggregations #126665

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

Open
iverase opened this issue Apr 11, 2025 · 1 comment
Open

terminate_after is not honour when size = 0 and query has aggregations #126665

iverase opened this issue Apr 11, 2025 · 1 comment
Assignees
Labels
:Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@iverase
Copy link
Contributor

iverase commented Apr 11, 2025

When a query is not collecting hits (size = 0) and contains aggregations, it does not honour the parameter terminate_after if defined. There are different incarnations of this bug depending on the value of track_total_hits. The two I have found out are:

  1. if track_total_hits is false it will never terminate early and will completely ignore the terminate_after parameter.

  2. if track_total_hits is true it might collect more documents that the one defined in terminate_after parameter.
    iff one or more segments fully match the query (we are collecting all doxuments of that segment).

There might more edge cases.

@iverase iverase added the :Search Foundations/Search Catch all for Search Foundations label Apr 11, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Apr 11, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-foundations (Team:Search Foundations)

@javanna javanna self-assigned this Apr 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Search Foundations/Search Catch all for Search Foundations Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

3 participants