# Compare fields

**URL:** <https://discuss.elastic.co/t/compare-fields/114514>\
**Category:** Elasticsearch\
**Created:** [January 8, 2018, 11:46am UTC](https://discuss.elastic.co/t/compare-fields/114514 "2018-01-08T11:46:56Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [January 8, 2018, 12:00pm UTC](https://discuss.elastic.co/t/compare-fields/114514/6 "2018-01-08T12:00:20Z")

</div>

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:

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

```

---

_[View the full topic](https://discuss.elastic.co/t/compare-fields/114514)._
