I'm using ElasticSearch version 5.1.
I'm trying to retrieve all documents, where the subtraction of two fields < |X|
Here is the query that I run:
post /my_idx/_search
{
"query": {
"bool": {
"must": {
"script": {
"script": {
"inline": "doc[\"f1\"].value - doc[\"f2\"].value < 9 && doc[\"f1\"].value - doc[\"f2\"].value > -9",
"lang": "painless"
}
}
}
}
}
}
I tried using the common mathematic function 'abs' without success.
How can I use this function in my query?
Thank you
You can simply use Math.abs(...)
method in painless
scripts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With