Using json input to get absolute (positive) number

(Dor Juravski) #1

I have a metric that only makes sense as an absolute number.
How can I turn a -5 to 5 using json input?
Note that this doesn't work, I need the number to be positive when I get a 5 or a -5

"script": "_value * -1 "

Thanks !

(Lee Drengenberg) #2

You could create a scripted field with Math.abs(doc['_value'].value)

(system) #3

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