# Creating buckets of a certain size from a set result size

**URL:** <https://discuss.elastic.co/t/creating-buckets-of-a-certain-size-from-a-set-result-size/67018>\
**Category:** Elasticsearch\
**Created:** [November 23, 2016, 4:55pm UTC](https://discuss.elastic.co/t/creating-buckets-of-a-certain-size-from-a-set-result-size/67018 "2016-11-23T16:55:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![barretodaniel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/barretodaniel/32/13373_2.png) [@barretodaniel](https://discuss.elastic.co/u/barretodaniel)\
**Post date:** [November 23, 2016, 4:55pm UTC](https://discuss.elastic.co/t/creating-buckets-of-a-certain-size-from-a-set-result-size/67018/1 "2016-11-23T16:55:59Z")

</div>

Hello all,

I'm trying to create 25 buckets of 5 documents each where I can then do sub-aggregations. So far my query looks like this:

```
"size": 125,
  "sort": [
    {
      "datetime": {
        "order": "desc"
      },
      "id": {
        "order": "desc"
      }
    }
  ]

```

The buckets I want will take the first five documents and put them together, then do the same with the remaining documents until I have 25 buckets. I tried a histogram aggregation but it was repeating documents and leaving out others.

Any ideas on what I can do?

---

<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:** [December 21, 2016, 4:56pm UTC](https://discuss.elastic.co/t/creating-buckets-of-a-certain-size-from-a-set-result-size/67018/2 "2016-12-21T16:56:00Z")

</div>

Closed on December 21, 2016, 4:56pm UTC

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