I'm facing the following issue. Say that you have an index in elasticsearch modeling a supermarket. You have a document for each time a customer shops something. So,
customer1, [list of bougth items], timestamp
customer2, [list of bougth items], timestamp
customer3, [list of bougth items], timestamp
customer2, [list of bougth items], timestamp
Now, it is possible that a customer come to the shop one time in his life, or he come every week, or everyday. So I record the timestamp indicating the time when he was buying something. I would like to compute the "average recurring time" of the customer to buy something. E.g. if a customer buys on 1sep, 7 sep and 30 sep, his average recurring time is: first interval: 7days second interval: 23 days average recurring time: (23+7)/2 = 15 days.
Do you know an aggregation that can help me to find out this statistic? The problem, for me, it's that I have only the timestamp of the day of buying and I haven't the differences between consecutive buying.
Thanks all.