# DSL query for matching two document fields

**URL:** <https://discuss.elastic.co/t/dsl-query-for-matching-two-document-fields/235333>\
**Category:** Elasticsearch\
**Created:** [June 2, 2020, 12:22pm UTC](https://discuss.elastic.co/t/dsl-query-for-matching-two-document-fields/235333 "2020-06-02T12:22:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![billy1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/billy1/32/127235_2.png) [@billy1](https://discuss.elastic.co/u/billy1)\
**Post date:** [June 2, 2020, 12:22pm UTC](https://discuss.elastic.co/t/dsl-query-for-matching-two-document-fields/235333/1 "2020-06-02T12:22:28Z")

</div>

Dears ,

am new to elastic community , i need your help to to write elastic query  
i have many documents created through logstash and i want to get the result were the documents have same result in different field ,

```auto
"filter": {
    "script": {
      "script": "doc['field1'].value == doc['field2'].value "
    }
  }
 }

```

i tried to filter out the result using above query but am getting " no field found for 'field2' in mapping with types "

also advise me how we can match two separate document fields in elk  
kindly advise me how can i get exact documents that have same value in two fields

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 30, 2020, 12:30pm UTC](https://discuss.elastic.co/t/dsl-query-for-matching-two-document-fields/235333/2 "2020-06-30T12:30:17Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
