Skip to content

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