# Scripted Field to check if the value of two attributes match or not

**URL:** https://discuss.elastic.co/t/scripted-field-to-check-if-the-value-of-two-attributes-match-or-not/143494
**Category:** Kibana
**Created:** [August 8, 2018, 10:51am UTC](https://discuss.elastic.co/t/scripted-field-to-check-if-the-value-of-two-attributes-match-or-not/143494 "2018-08-08T10:51:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Hugo\_Faria](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hugo\_Faria](https://discuss.elastic.co/u/Hugo_Faria)
#### Post date: [August 8, 2018, 10:51am UTC](https://discuss.elastic.co/t/scripted-field-to-check-if-the-value-of-two-attributes-match-or-not/143494/1 "2018-08-08T10:51:04Z")

</div>

Hi there,

I'm trying to create a scripted field to compare 2 values:

_doc['incoming\_json\_dict.customer.correspondenceLanguage'].value_  
and  
_doc['result\_pack.detectedLanguage'].value_

I tried out different way to check it but it doesn't work.  
both are of type string, aggregatable and searchable.

any help to create the painless code to get for example True / False if the values are equal?

thanks and cheers,  
Hugo

---

<div class="post-metadata">

### Author: ![Catherine\_Liu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catherine_liu/32/34294_2.png) [@Catherine\_Liu](https://discuss.elastic.co/u/Catherine_Liu)
#### Post date: [August 8, 2018, 7:37pm UTC](https://discuss.elastic.co/t/scripted-field-to-check-if-the-value-of-two-attributes-match-or-not/143494/2 "2018-08-08T19:37:53Z")

</div>

Did you try a script like `doc['incoming_json_dict.customer.correspondenceLanguage'].value === doc['result_pack.detectedLanguage'].value`? It should work with these settings:

 ![13%20PM](https://us1.discourse-cdn.com/elastic/original/3X/d/a/da01d29f6d391854fc146ef49b3499c4f1d62f1c.png)

Here's are links to our [painless syntax reference page](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/modules-scripting-painless-syntax.html) and a blog post on [using painless in scripted fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields). They provide some nice examples of painless scripts.

---

<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: [September 5, 2018, 7:37pm UTC](https://discuss.elastic.co/t/scripted-field-to-check-if-the-value-of-two-attributes-match-or-not/143494/3 "2018-09-05T19:37:53Z")

</div>

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