Sorting Followed by Aggregation

I want ten distinct values from category field but I don't want random distinct values. The ten distinct values must be latest (uploadedDate field sort desc).

By default, the aggregations are sorted by doc_count descendant, it's not random.
But maybe to achieve what you want, you could use the field collapsing feature.

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-collapse.html

So, you can still sort by uploadedDate field, and collapse on the category field.

Klof, Thank You for the solution.

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