How do I get the total no of buckets for the bucket aggregation

17 views Asked by At

I need to get only the total possible no of buckets for a bucket aggregation.

I am trying to get the no of docs with duplicate value for a email field. I used the following aggregate query to get the no of emails with the duplicate email.

GET profiles_users/_search
{
  "size": 0, 
  "aggs": {
    "duplicate_emails": {
      "terms": {
        "field": "users.email.exact",
        "min_doc_count": 2,
        "size" = 10000
      },
      "aggs": {
        "total_docs": {
          "value_count": {
            "field": "users.email.exact"
          }
        }
      }
    },
    "total_buckets": {
      "stats_bucket": {
        "buckets_path": "duplicate_emails>total_docs"
      }
    }
  }
}```

The above query solves the same but have a limitation of 10000 docs only. I tried using the composite but could not use the min doc count there.
0

There are 0 answers