I am having filed "_type" with values 'call-end', 'call-attempt' and more. I want to divide count of 'call-attempt' with count of 'call-end' (failure/success) and display it in heatmap.
Here is my JSON input:
{"script": {
"lang": "painless",
"inline": "int totalSuccess = 0; int totalFailure = 0; for (int i = 0; i < doc['_type'].length; ++i) { if(doc['_type'][i] =='call-end') {totalSuccess += 1;} if(doc['_type'][i] == 'call-attempt'){totalFailure +=1;}} return totalFailure/totalSuccess ;"
}
}
If I return only 'totalFailure' or 'totalSuccess' it returns correct number. But if I want to divide it, it shows error - division by zero. But none of the value is zero.
What is the problem?
I don't have search I have this script inside visualization. How can I open it in Dev Tools?
This is my request. If I use aggregation "count" it ignores my JSON input field. So I use sum on field that is zero.
I have also tried scripted field that has only 1 and 0 and use the aggregation sum on it and just divide the result by for cycle to sum count of another value but it wasn't working either. When I used "_value" for result it showed nullpointer exception.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.