How do i create a aggregation with scripted field using Elastic High level client ?
Kibana query like below
GET itil_incidents/_search
{
"size": 0,
"aggs": {
"create_date": {
"date_histogram": {
"field": "Incident_Create_Date",
"interval": "1d",
"format": "MM-dd-yyyy"
},
"aggs": {
"avg_date_diff": {
"avg": {
"script": {
"lang": "painless",
"source": "Math.round((doc.Incident_Close_Date.value.millis-doc.Incident_Create_Date.value.millis))"
}
}
}
}
}
}
}