Painless help

(Trevor Dodds) #1


Trying to use the example I'm trying to count the values for 'count_value' field then multiple the result by busy. For some odd reason I can use +, - but * just returns the busy value.

I'm trying to run the below.

double busy = _value; double total = 0; for (int i = 0; i < doc['count_value'].length; ++i) { total += doc['count_value'][i]; } return busy * total;

Is there a better way to run something like this?


(Trevor Dodds) #3

I've made little progress.

count_value is a value of 1 for every hour. I use this to "sum" the hours in a day or multiple days selected from the time range. example a range of "yesterday" = 24.

 ((_value * 0.10) / (doc['count_value'].value * 10))*100

This works well, the result is 24 for "yesterday" for each hour in the day. But the above doc['count_value'].value is not the total for the range but rather the value for the hour = 1.

Is it possible with an inline script to get the total of doc['count_value'].value of the entire range to be used in each bucket calculation? Or a way to pass the "bucket count" back to the script?


(system) #4

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