# Time based aggregation and combinatorics

**URL:** <https://discuss.elastic.co/t/time-based-aggregation-and-combinatorics/49887>\
**Category:** Elasticsearch\
**Created:** [May 12, 2016, 11:09am UTC](https://discuss.elastic.co/t/time-based-aggregation-and-combinatorics/49887 "2016-05-12T11:09:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elkonaut](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@elkonaut](https://discuss.elastic.co/u/elkonaut)\
**Post date:** [May 12, 2016, 11:09am UTC](https://discuss.elastic.co/t/time-based-aggregation-and-combinatorics/49887/1 "2016-05-12T11:09:30Z")

</div>

Hi there,

my documents indexed look as the following  
{  
"category" : "book",  
"title" : "sometitle",  
"sold\_at": yyyy-MM-dd, HH:mm:ssZ  
}

I would like to find out:  
how often which combination of books is bought within a specific time frame (e.g. one hour after the first book was bought).

Hopefully the following example explains it better:

Book A is bought at 8:00 o'clock  
Book B is bought at 8:10 o'clock  
....  
Book A is bought at 10:00 o'clock  
Book B Is bought at 10:02 o'clock

I am pondering if this can be done with elasticsearch and if yes, what aggregation I should use:

- it should be a time based aggregation as I am interested in a certain time interval
- the time interval starts at the date sold\_at
- the aggregation should consider multiple combinations of the book titles (it is not a static value)

---

<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:** [July 5, 2017, 10:52pm UTC](https://discuss.elastic.co/t/time-based-aggregation-and-combinatorics/49887/2 "2017-07-05T22:52:08Z")

</div>

Closed on July 5, 2017, 10:52pm UTC


