Last N documents aggregation

Hello,
I want to make aggregation of last N documents(for example 100) for watcher alerts.
Is this possible to use count of documents, not time??

"body": {
      "size": 0,
      "query": {
        "bool": {
          "filter": {
            "range": {
              "date": {
                "from": "now-30m",
                "to": "now"
              }
            }
          }
        }
      },
      "aggs": {
        "operator": {
          "terms": {
            "field": "operator.keyword"
          }
        }
      }
    }

Above is my aggregation base on time. I need the same but based on the documents count.
Thank you

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