# All results in aggregate ES5.x

**URL:** <https://discuss.elastic.co/t/all-results-in-aggregate-es5-x/69178>\
**Category:** Elasticsearch\
**Created:** [December 15, 2016, 3:03pm UTC](https://discuss.elastic.co/t/all-results-in-aggregate-es5-x/69178 "2016-12-15T15:03:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjanzen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pjanzen/32/13756_2.png) [@pjanzen](https://discuss.elastic.co/u/pjanzen)\
**Post date:** [December 15, 2016, 3:03pm UTC](https://discuss.elastic.co/t/all-results-in-aggregate-es5-x/69178/1 "2016-12-15T15:03:46Z")

</div>

Hi,

In ES 2.x I was able to run an aggregate query with size 0 which give me all buckets. However in ES5.x this size must be set positive which is \>= 1.

I have been reading the docs but I cannot figure out how to get all the results from for example the aggregate below. I hope someone can help.

Paul.

```
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "_exists_:imp_to",
            "analyze_wildcard": true
          }
        },
        {
          "range": {
            "@timestamp": {
              "gte": 1481756400000,
              "lte": 1481813630636,
              "format": "epoch_millis"
            }
          }
        }
      ],
      "must_not": []
    }
  },
  "size": 0,
  "aggs": {
    "2": {
      "terms": {
        "field": "imp_to.keyword",
        "size": 1,
        "order": {
          "_count": "desc"
        }
      }
    }
  }
}

```

The result I now have is this.

```
{
  "took": 5444,
  "timed_out": false,
  "_shards": {
    "total": 8,
    "successful": 8,
    "failed": 0
  },
  "hits": {
    "total": 20082958,
    "max_score": 0,
    "hits": [

    ]
  },
  "aggregations": {
    "2": {
      "doc_count_error_upper_bound": 1461,
      "sum_other_doc_count": 20076219,
      "buckets": [
        {
          "key": "x-lxxxxxw@nabcded.com",
          "doc_count": 6739
        }
      ]
    }
  }
}
```

---

<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:** [January 12, 2017, 3:03pm UTC](https://discuss.elastic.co/t/all-results-in-aggregate-es5-x/69178/2 "2017-01-12T15:03:52Z")

</div>

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