# Elasticsearch determinte bucket length in aggregation

**URL:** <https://discuss.elastic.co/t/elasticsearch-determinte-bucket-length-in-aggregation/149415>\
**Category:** Elasticsearch\
**Created:** [September 21, 2018, 8:09am UTC](https://discuss.elastic.co/t/elasticsearch-determinte-bucket-length-in-aggregation/149415 "2018-09-21T08:09:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![94a1388a854580b1f815](https://avatars.discourse-cdn.com/v4/letter/9/fbc32d/32.png) [@94a1388a854580b1f815](https://discuss.elastic.co/u/94a1388a854580b1f815)\
**Post date:** [September 21, 2018, 8:10am UTC](https://discuss.elastic.co/t/elasticsearch-determinte-bucket-length-in-aggregation/149415/1 "2018-09-21T08:10:00Z")

</div>

please help me with understanding nested bucket aggregation in elastic search. I have next query aggregation results:

```
 [...]
{
  "key": "key1",
  "doc_count": 1166,
  "range_keys": {
    "doc_count_error_upper_bound": 0,
    "sum_other_doc_count": 0,
    "buckets": [
      {
        "key": "happy",
        "doc_count": 1166
      }
    ]
  }
},
{
  "key": "key2",
  "doc_count": 1123,
  "range_keys": {
    "doc_count_error_upper_bound": 0,
    "sum_other_doc_count": 0,
    "buckets": [
      {
        "key": "cookies",
        "doc_count": 1122
      },
      {
        "key": "happy",
        "doc_count": 1
      }
    ]
  }
},

```

[...]

As you see, i have query results with only "happy", but i need to get **all** results **only** with "happy" and "cookies".

In order to achieve this goal i tried to use "size" argument, but this argument gave e results with size and less results query.

How i can determine "bucket" length in nested query?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 19, 2018, 8:10am UTC](https://discuss.elastic.co/t/elasticsearch-determinte-bucket-length-in-aggregation/149415/2 "2018-10-19T08:10:07Z")

</div>

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