How to use ABS function in ElasticSearch equery?
c#, elasticsearch
Solution
You can simply use `Math.abs(...)` method in `painless` scripts.
Problem
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