# How to search two fields has the same value

**URL:** <https://discuss.elastic.co/t/how-to-search-two-fields-has-the-same-value/78541>\
**Category:** Elasticsearch\
**Created:** [March 14, 2017, 2:44pm UTC](https://discuss.elastic.co/t/how-to-search-two-fields-has-the-same-value/78541 "2017-03-14T14:44:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin-tang-rs](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@kevin-tang-rs](https://discuss.elastic.co/u/kevin-tang-rs)\
**Post date:** [March 14, 2017, 2:44pm UTC](https://discuss.elastic.co/t/how-to-search-two-fields-has-the-same-value/78541/1 "2017-03-14T14:44:58Z")

</div>

There are two fields, id\_cur and id\_steady, i hope to query the content which id\_cur == id\_steady, how to implement, thank you

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 14, 2017, 3:33pm UTC](https://discuss.elastic.co/t/how-to-search-two-fields-has-the-same-value/78541/2 "2017-03-14T15:33:09Z")

</div>

You can do that with a script but that will be slow.  
I'd recommend doing that comparison at index time and store the result in a new field.

---

<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:** [April 11, 2017, 3:33pm UTC](https://discuss.elastic.co/t/how-to-search-two-fields-has-the-same-value/78541/3 "2017-04-11T15:33:11Z")

</div>

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