How to paging the buckets after aggregation

I remove the duplicate result and got the final result of this format, how to paging ths buckets ?

"aggregations": {
    "ip_aggs": {
      "doc_count_error_upper_bound": 1391,
      "sum_other_doc_count": 5071763,
      "buckets": [
        {
          "key": "94.187.31.58",
          "doc_count": 1459,
          "top_hits": {。。。}
        },
       {
          "key": "94.187.31.58",
          "doc_count": 1459,
          "top_hits": {。。。}
        },
       {
          "key": "94.187.31.58",
          "doc_count": 1459,
          "top_hits": {。。。}
        },
      {
          "key": "94.187.31.58",
          "doc_count": 1459,
          "top_hits": {。。。}
        },
       {
          "key": "94.187.31.58",
          "doc_count": 1459,
          "top_hits": {。。。}
        },
       {
          "key": "94.187.31.58",
          "doc_count": 1459,
          "top_hits": {。。。}
        }
    ]
  }
}

Hi,

Please:
1°/ Expose your problem
2°/ Format your code
3°/ Give your versions
4°/ Say "hi", "thanks" and "bye"

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html

bye,
Xavier

1 Like

Thanks for telling me this, the code is format ,es version is 5.6.4,
the problem is the buckets name ip_aggs has too long length,i want to page it

Thanks a million

bye

Hi, can you paste the code of your query to see how is done your aggregation ?

bye,
Xavier

hello,thanks a lot,the query is as follow

POST search-v1/info/_search
{
  "size": 0, 
  "query": {
    "match_all": {}
  },
  "aggs": {
    "ip_aggs": {
      "terms": {
        "field": "ip",
        "size": 1000
      },
      "aggs": {
        "top_hits": {
          "top_hits": {
            "size": 1
          }
        }
      }
    }
  }
}

i want to page the aggs result

bye

iamazy

Hi,

You should read the doc here: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html

If you want to retrieve all terms or all combinations of terms in a nested terms aggregation you should use the Composite aggregation which allows to paginate over all possible terms rather than setting a size greater than the cardinality of the field in the terms aggregation. The terms aggregation is meant to return the top terms and does not allow pagination.

Note that your results are pretty strange, because bucket => "key": "94.187.31.58", should be different on each result...

bye,
Xavier

2 Likes

hello xavier,
thanks again,
i removed the key information of result and converted into the same

bye
iamazy

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