Elasticsearch Aggregation Pagination

3.4k Views Asked by At

Is there any way to do pagination using Elastic search with aggregation? the elasticsearch version is 2.3. This is the query:

{
  "query": {
    "match": {
      "clientMac": "88:"
    }
  },
  "aggs": {
    "top_tags": {
      "terms": {
        "field": "clientMac.rawData"
      },
      "aggs": {
        "top_client_hits": {
          "top_hits": {
            "sort": [
              {
                "event_timestamp": {
                  "order": "desc"
                }
              }
            ],
            "_source": {
              "includes": [
                "event_timestamp"
              ]
            },
            "size": 1
          }
        }
      }
    }
  }
}
1

There are 1 best solutions below

0
On

From elastic 5 you do have the ability by partitioning the buckets of terms aggregation. You can read about it here: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/search-aggregations-bucket-terms-aggregation.html#_filtering_values_with_partitions