Hi
I have divided two fields using below script
return doc['StatusOpen'].value/doc['StatusSent'].value
for this result should be 2/31 = 0.06451 = 6.451% but it's giving 0 %
As I have format as percentage and Numeral.js format pattern as 0,0.[000]%
May I know where I went wrong.
flash1293
(Joe Reuter)
January 28, 2021, 12:26pm
2
StatusOpen
and StatusSent
are probably of type int
- in this case the /
operator is doing an integer division. By casting them to double it should work as expected (https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-casting.html ):
return ((double) doc['StatusOpen'].value)/((double) doc['StatusSent'].value)
Awesome!! it's working @flash1293
system
(system)
Closed
February 25, 2021, 12:38pm
4
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.