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?