# ES Aggregation hit that can fit multiple buckets should be in all buckets

**URL:** https://discuss.elastic.co/t/es-aggregation-hit-that-can-fit-multiple-buckets-should-be-in-all-buckets/104378
**Category:** Elasticsearch
**Created:** [October 18, 2017, 10:59am UTC](https://discuss.elastic.co/t/es-aggregation-hit-that-can-fit-multiple-buckets-should-be-in-all-buckets/104378 "2017-10-18T10:59:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ojamui](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@ojamui](https://discuss.elastic.co/u/ojamui)
#### Post date: [October 18, 2017, 10:59am UTC](https://discuss.elastic.co/t/es-aggregation-hit-that-can-fit-multiple-buckets-should-be-in-all-buckets/104378/1 "2017-10-18T10:59:55Z")

</div>

Hey all

Im trying to solve a BI problem for my company, and we utilize ES for most of our statistics

Lets say i have 2 date fields in an entry. now lets say that those two dates are from the same date and are only a couple of hours apart. effectively those two fields combine to a date range of ( t0 \< x \< t1 )

now lets say i want a date histogram aggregation (or some other form of temporal bucket creation) that will tell me for each hour, if a hit was found.

Example, i have an entry with the data fields of 09:00 and 12:00 as the hours  
i want that same single entry to be counted towards the buckets of 09:00-10:00, 10:00-11:00, and 11:00-12:00 - thus having a single hit counted in 3 different buckets

is this possible? if so then how?  
Thanks in advance!

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [October 18, 2017, 12:02pm UTC](https://discuss.elastic.co/t/es-aggregation-hit-that-can-fit-multiple-buckets-should-be-in-all-buckets/104378/2 "2017-10-18T12:02:38Z")

</div>

I think that [Range Datatype](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/range.html) can be helpful.

But unfortunately there is no built in yet range datatype agg.  
On the other hand you can "easily" build a filter aggregation for each bucket you want and filter by using a `range` query.

That should work even though it requires you to write manually 24 filter aggs.

---

<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: [November 15, 2017, 12:02pm UTC](https://discuss.elastic.co/t/es-aggregation-hit-that-can-fit-multiple-buckets-should-be-in-all-buckets/104378/3 "2017-11-15T12:02:49Z")

</div>

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