Hi Community,
I want to run this query
GET employees/_search
{
"aggs": {
"Total Income": {
"sum": {
"field": "Package",
"script": {
"source": "if(params._source['name.keyword']=='Elan'){return params._source['Package']?.toString().length();}"
}
}
}
}
}
I am getting the below error
{
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": """Cannot invoke "java.lang.Number.doubleValue()" because the return value of "org.elasticsearch.script.AggregationScript.execute()" is null"""
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "employees",
"node": "WYRlvdsyTZSiqp3UTsTguQ",
"reason": {
"type": "null_pointer_exception",
"reason": """Cannot invoke "java.lang.Number.doubleValue()" because the return value of "org.elasticsearch.script.AggregationScript.execute()" is null"""