Using aggr query over a specific size of result instead of entire index

I am fairly new to Elasticsearch.
I want to find the avg of only the most recent 50 results instead of my entire index. Is there any way I can do it?
I cannot find a query with which I can aggr over specific size and ordering of result.

I think you'll have to try to do this in 2 steps. The initial query gets you the top 50 documents (along with the attribute in the document which you want to aggregate) based on some timestamp attribute. And then you can perform a quick average operation(doesn't have to be a part of ES you can use any programming language to do this) on the values returned by the first query.

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