0

Is there any solution in my query with terms aggregation from:

{
    "size":0
    ,"aggs":{
        "packageid":{
            "terms":{
                "field":"packageId",
                "size":10,
                "from":10
            },
            "aggs": {
                "top_tag_hits": {
                    "top_hits": {
                        "sort": [
                            {
                                "version": {
                                    "order": "desc"
                                }
                            }
                        ],
                        "size" : 1
                    }
                }
            }
        }
    }
}

I want from, size in terms aggregation to paging top 10 lastest version package start index 10 and end index 20.

Giau Huynh
  • 300
  • 3
  • 15
  • Possible duplicate of [How to control the elasticsearch aggregation results with From / Size?](https://stackoverflow.com/questions/43038131/how-to-control-the-elasticsearch-aggregation-results-with-from-size) – John Jones Aug 09 '17 at 00:46
  • 1 year, 8 months ago & 4 months ago, this question has duplicate my question? – Giau Huynh Aug 09 '17 at 01:50
  • It's not a race lol, the flag is only intended to direct other people who might have the same question to an answer that may help them – John Jones Aug 09 '17 at 01:51

2 Answers2

0

If I'm not mistaken, aggregations currently don't support paging, so you'd have to implement it client side

0

Since pagination over aggregation is not supported.So you can fetch all the buckets during aggregation and then on client side handle the pagination. You need to modify your query to "size":100000. Fetch all the buckets and apply pagination in service layer.

wonder
  • 193
  • 1
  • 13