Elasticsearch bucket aggregations with Painless scripts returning invalid division values

Hi ,

I am a newbie to Elasticsearch and following is my query:
I have an index where I have maintained the counters (int) for various HTTP codes. So in order to show the success/ failure which are working as expected. I am trying to show the % Success as a new field. When I am trying to compute Success Percent with the painless script as

def sum_succ = myListSuccess.get(0) + myListSuccess.get(1) + myListSuccess.get(2) + myListSuccess.get(3);
def sum_fail = 0;
for (int i = 0; i < myListFail.length; ++i) {
            sum_fail += myListFail.get(i);
          }
def sumAll = sum_succ + sum_fail;
def succPercent = sum_succ / sumAll;
return succPercent;

When I am returning this value as a field, for a few cases the values are absolutely fine, but for some of the cases its returning below values:

  1. Showing NaN value.
  2. Showing the value as greater than 1 which is impossible to get with the above code.
  3. Already updated the query accordingly to update missing values as 0.

Am I missing something here, Please suggest.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.