Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Opensearch v1.1.0
Describe the issue:
I have an extraction query response with values “Error_count”: 10 and “Success_count”: 8858, but the following evaluates to true
:
ctx.results[0].aggregations.Error_count / ctx.results[0].aggregations.Success_count == 0.0
How can I properly cast these numbers to get the right precision? Or is there a division function built-in?
ETA: adding .floatValue()
(Value (Groovy 4.0.7)) to both of my variables appears to have done the trick, based on some googling & seeing “Painless is the default OpenSearch scripting language and has a syntax similar to Groovy.” here: Monitors - OpenSearch documentation
Now the following evaluates to false
:
ctx.results[0].aggregations.2.buckets.Error.doc_count.floatValue() / ctx.results[0].aggregations.2.buckets.Success.doc_count.floatValue() > 0.002
and this evaluates to true
:
ctx.results[0].aggregations.2.buckets.Error.doc_count.floatValue() / ctx.results[0].aggregations.2.buckets.Success.doc_count.floatValue() > 0.001