# Analytics on new customers versus returning customers

**URL:** <https://discuss.elastic.co/t/analytics-on-new-customers-versus-returning-customers/22732>\
**Category:** Elasticsearch\
**Created:** [March 18, 2015, 9:27am UTC](https://discuss.elastic.co/t/analytics-on-new-customers-versus-returning-customers/22732 "2015-03-18T09:27:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Spiewak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vincent_spiewak/32/828_2.png) [@Vincent\_Spiewak](https://discuss.elastic.co/u/Vincent_Spiewak)\
**Post date:** [March 18, 2015, 9:27am UTC](https://discuss.elastic.co/t/analytics-on-new-customers-versus-returning-customers/22732/1 "2015-03-18T09:27:30Z")

</div>

Dear community,

I struggle to find a solution for an aggregation use-case...

We index transactions in Elasticsearch from an e-commerce like this :

{ "email" : "client1@gmail.com", "amount" : 15.99, "timestamp" :  
"2015-03-18T06:15:03Z" }

We would like to calculate the ratio of new customers versus returning  
customers in a selected time range.  
In others words, calculate how much customers made a single transaction  
versus customers with more than one transaction.  
Moreover, we would like to calculate the average amount of transaction for  
new customers versus returning customers.

A term aggregation on email will produce buckets per email, but we need to  
retrieve all customers to be able to calculate the ratio...

Do you have any idea on how to achieve this without ?

Is there a way to create two buckets, one grouping new customers, and one  
grouping returning customers ?

Best Regards

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/89da7fff-b0f4-495b-9986-c6dd20c3735a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/89da7fff-b0f4-495b-9986-c6dd20c3735a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:25am UTC](https://discuss.elastic.co/t/analytics-on-new-customers-versus-returning-customers/22732/2 "2017-07-06T00:25:57Z")

</div>

Closed on July 6, 2017, 12:25am UTC


