Unable to order by top hits results

Hi guys,
I'm trying to create a pie chart that will show the most recent docs using the Top Hit aggregation, then aggregate them by some field and sort them by the results of the Top Hit. Here's what I did:

As you can see above, the sort is not correct, this is because i sort by the max value of the totalSoreSize field, over the last 7d, but I was expecting to have it sorted based on the returned results from the Top Hit.

Is there any way to make this work?

1 Like

I think the sort is done by the last Split aggregation that you have added. Can you try and switch them around to see if it works?

I use only 1 split (Terms), the other one is just the metric based on Top hits, i cannot switch between them

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.