I need to build an aggregation using Java API:
GET /sales/t/_search
{
"aggs": {
"group_by_month": {
"terms": {
"script": "def opDate = new DateTime(doc['date'].date); opDate.getMonthOfYear()",
"order": {
"_term": "asc"
}
}
}
}
}
Up to now, I've been able to create an terms aggregation, however, I'm not able to provide the script:
AggregationBuilders.terms(this.getName()).field(this.getName()).script(??????????)
Which's the way to provide an inline script using Java API?