Home > Net >  Elasticsearch where dividing two field is bigger than
Elasticsearch where dividing two field is bigger than

Time:11-08

Trying to make a boolean query where 'X/Y>0.60'.

Couldn't make It with no logic.

Need help for making logic.

CodePudding user response:

You could use a script query in a filter context. Here's an example:

{
  "query": {
    "bool": {
      "filter": {
        "script": {
          "script": {
            "source": "doc.x.value / doc.y.value == params.foo",
            "params": {
              "foo": 0.60
            }
          }
        }
      }
    }
  }
}
  • Related