# Find Term Repeat - User Retention

**URL:** https://discuss.elastic.co/t/find-term-repeat-user-retention/91879
**Category:** Elasticsearch
**Created:** [July 5, 2017, 10:31am UTC](https://discuss.elastic.co/t/find-term-repeat-user-retention/91879 "2017-07-05T10:31:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yumweb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yumweb/32/19781_2.png) [@yumweb](https://discuss.elastic.co/u/yumweb)
#### Post date: [July 5, 2017, 10:31am UTC](https://discuss.elastic.co/t/find-term-repeat-user-retention/91879/1 "2017-07-05T10:31:01Z")

</div>

Hi There,

We have a bunch of sale data indexed in elasticsearch. The data looks something like below

```
{
	"_index": "sales",
	"_type": "sale",
	"_id": "1",
	"_version": 1,
	"found": true,
	"_source": {
		"sale_id": 1,
		"show_comment_on_receipt": 0,
		"did_redeem_discount": 0,
		"deleted_by": 1,
		"location_id": 2,
		"was_layaway": 0,
		"@version": "1",
		"signature_image_id": null,
		"tier_id": null,
		"deleted_taxes": null,
		"points_gained": 0,
		"points_used": 0,
		"sale_location_id": 1,
		"sale_package": 0,
		"was_appointment": 0,
		"cc_ref_no": "",
		"suspended": 1,
		"auth_code": "",
		"register_id": 2,
		"was_estimate": 0,
		"payment_type": "Cash: Rs.1,000.00<br />",
		"deleted": 1,
		"store_account_payment": 0,
		"@timestamp": "2017-07-05T09:34:39.362Z",
		"sold_by_employee_id": 1,
		"employee_id": 1,
		"comment": "",
		"customer_id": 2,
		"sale_time": "2016-09-21T08:57:11.000Z",
"customer_create_date": "sale_time": "2016-09-21T08:57:11.000Z"
	}
},
{
	"_index": "sales",
	"_type": "sale",
	"_id": "33",
	"_version": 1,
	"found": true,
	"_source": {
		"sale_id": 33,
		"show_comment_on_receipt": 0,
		"did_redeem_discount": 0,
		"deleted_by": null,
		"location_id": 13,
		"was_layaway": 0,
		"@version": "1",
		"signature_image_id": null,
		"tier_id": null,
		"deleted_taxes": null,
		"points_gained": 2.0000000000,
		"points_used": 0,
		"sale_location_id": 8,
		"sale_package": 0,
		"was_appointment": 0,
		"cc_ref_no": "",
		"suspended": 0,
		"auth_code": "",
		"register_id": 14,
		"was_estimate": 0,
		"payment_type": "Debit Card: Rs.201.25<br />",
		"deleted": 0,
		"store_account_payment": 0,
		"@timestamp": "2017-07-05T09:34:40.349Z",
		"sold_by_employee_id": 26,
		"employee_id": 26,
		"comment": "",
		"customer_id": 105,
		"sale_time": "2016-10-05T10:39:35.000Z"
"customer_create_date": "sale_time": "2016-09-21T08:57:11.000Z"
	}
}

```

We now need to find out the number of unique customers visited in one month and out of them the number of visitors how have come again in the subsequent month.

We have 2 time based data — `sale_time` and `customer_create_date`.

We are able to get the unique visits based on `customer_create_date` But we need a way to figure out if the unique visitor has repeated in the subsequent month.

So for instance, in the month if January there were 200 unique visitors and out of them 80 came back again and did a sale.

What is the option to do this?

---

<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: [August 2, 2017, 10:31am UTC](https://discuss.elastic.co/t/find-term-repeat-user-retention/91879/2 "2017-08-02T10:31:04Z")

</div>

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