Top Hits within Top Hits and custom key sorting with explicit order

Hi all,

Assume that we have a field with N unique values. Documents are grouped by
these N unique values.

We want to create a Top Hits aggregation, and create for each bucket
another Top Hits aggregation. We use the nested / deeper Top Hits
Aggregation to create groups based on these N unique values.

Question: is this possible in ES?

However, we do not want to sort the keys within an bucket by a field in
ascending or descending order, but by providing by the list of N unique
values in an explicit order using a list.
We do not want to sort it by relevance score based on the main query as

I guess we can do this sorting on the application side, since the list of N
unique values will be limited.


You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit