Hi,
I am using ElasticSearch 6.2 and I have one query to get record counts for Monthly data for particular period. I want to include 6 Month data record count in same bucket whereas 6 Months should not consider current month.
Can you please help me to find a way to get Last 6 Month counts from current month bucket. For example - If monthly data is for Feb-2019, then last 6 Month data count I want is from Aug-2018 to Jan-2019(Means leave Feb-2019) and if monthly data is for April-2019 then 6 month count required will be from Oct-2018 to Mar-2019.
Below is the sample code which currently I am using for getting monthly aggregation portwise -
{
"aggs": {
"GroupByPortId": {
"terms": {
"field": "portId",
"size": 10000
},
"aggs": {
"LocalPortBuckets": {
"date_histogram": {
"field": "date",
"interval": "month",
"min_doc_count": 0,
"order": {
"_key": "desc"
},
"extended_bounds": {
"min": null,
"max": null
}
}
}
}
}
}
}