Time based aggregation and combinatorics

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)