Skip to content

[8.6] Avoid doing I/O when fetching min and max for keyword fields (#92026) #92854

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

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

javanna
Copy link
Member

@javanna javanna commented Jan 11, 2023

Backports the following commits to 8.6:

…#92026)

Whenever sorting on a date, numeric or keyword field (as primary sort), the can_match phase retrieves min and max for the field and sorts the shards (asc or desc depending on the sort order) so that they are going to be queried following that order. This allows incremental results to be exposed in that same order when using async search, as well as optimizations built on top of such behaviour (elastic#51852).

For fields with points we call `getMinPackedValue` and `getMaxPackedValue`, while for keyword fields we call `Terms#getMin` and `Terms#getMax`. Elasticsearch uses `FilterTerms` implementations to cancel queries as well as to track field usage. Such filter implementations should delegate their `getMin` and `getMax` calls to the wrapped `Terms` instance, which will leverage info from the block tree that caches min and max, otherwise they are always going to be retrieved from the index, which does I/O and slows the can_match phase down.
@javanna javanna added :Search/Search Search-related issues that do not fall into other categories >bug backport Team:Search Meta label for search team labels Jan 11, 2023
@javanna javanna merged commit 5052911 into elastic:8.6 Jan 12, 2023
@javanna javanna deleted the backport/8.6/pr-92026 branch January 12, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport >bug :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.6.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants