Compare fields

You can only put one query in each must clause in the must array, you need to separate your script and match queries into separate objects. However the replies by @val are also true and you would have reached those issues next I suspect.

Try this:

{
  "query": {
    "bool": {
      "must": [
        {
          "script": {
            "script": {
              "source": "doc['email.keyword'].value == doc['redirect.keyword'].value",
              "lang": "painless"
            }
          }
        },
        {
          "match": {
            "program": "get_forwarding_address"
          }
        } 
      ]
    }
  }
}
1 Like