Is your feature request related to a problem?
The query
| stats count() as cnt by a, b | sort cnt
will push down to a composite aggregation with 1000 buckets. So the sort by cnt only sorts on the 1000 records. The result is incorrect.
What solution would you like?
Push down such case to multi-terms aggregation https://docs.opensearch.org/latest/aggregations/bucket/multi-terms/
What alternatives have you considered?
A clear and concise description of any alternative solutions or features you've considered.
Do you have any additional context?
Add any other context or screenshots about the feature request here.