Need the stats in unique customer: index contains customers orders data.
Ex:
{
"_index" : "customers_orders",
"_type" : "_doc",
"_id" : "109126",
"_score" : 1.0,
"_source" : {
"total_net" : 64.97,
"orders_platform" : 2,
"origin_country" : "DE",
"currency_iso" : "EUR",
"internal_id" : 650,
"ext_platforms_reference" : "T",
"total_vat" : 12.35,
"platform" : "eShopingcart",
"@version" : "1",
"orders_promised_shipping_date" : "2018-07-14T11:45:35.000Z",
"orders_shipping_type" : 2,
"created_at" : "2021-05-09T09:13:25.000Z",
"@timestamp" : "2021-06-23T03:25:22.448Z",
"delivery_country" : "DE",
"orders_comments" : "Special",
"row_version" : "0x00000000002F25BA",
"orders_language" : "DE",
"ext_payments_reference" : null,
"source_from" : 1,
"updated_at" : "2021-05-09T09:13:58.000Z",
"orders_date" : "2018-07-14T11:43:52.000Z",
"orders_reference" : "VAP-19641-AT",
"currency_factor" : 1.0,
"id" : 109126,
"orders_payment_type" : null,
"order_status" : 1,
"total_gross" : 77.32,
"customer_id" : 47070
}
}
Need to identify
Blockquote
customers falling in particular range and not orders in betwenn.
So far tried.
{
"track_total_hits": true,
"query": {
"bool": {
"must": [
{
"range": {
"orders_date": {
"gte": "2020-06-26",
"lte": "2021-06-26"
}
}
}
]
}
},
"aggs": {
"NAME": {
"terms": {
"field": "customer_id",
"size": 10000
},
"aggs": {
"order_date": {
"terms": {
"field": "orders_date",
"size": 10
}
}
}
}
}
}
- How to compare customers multiple orders in aggregation result