Hi!
I want to use script fields inside Aggregate, I wrote this query:
GET test/_search
{
"size":0,
"query": {
"bool": {
"filter": [
{
"term": {
"eventType": 5
}
},
{
"range": {
"createdDate": {
"gte": "2018-01-01",
"lt": "2019-01-01"
}
}
}
]
}
},
"script_fields": {
"script_sum": {
"script": {
"lang": "painless",
"source": " doc['price'].value * doc['audrate'].value"
}
}
},
"aggs": {
"months": {
"date_histogram": {
"field": "createdDate",
"calendar_interval": "month",
"format": "MM-MMMM"
},
"aggs": {
"test": {
"sum": {
"field": "script_sum"
}
}
}
}
}
}
but the output result does not have any value for the script field "script_sum".
Is it possible to use script fields in aggregates or not?
I am using this version of ES 7.2