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)