Aggregate after sort+size

I can get the newest document before a certain timestamp with this query (hopefully with reasonable performance):

{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "timestamp": {
              "lt": 1508010043
            }
          }
        }
      ]
    }
  },
  "sort": {
    "timestamp": "desc"
  },
  "size": 1
}

How can I run an aggregation on it?

Sort and size have no affect on aggregations. Aggregations have their own
sort and size parameters, wherever applicable.

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