Sorting Followed by Aggregation


(Deepak Gupta) #1

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).


#2

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.


(Deepak Gupta) #3

Klof, Thank You for the solution.


(system) #4

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