# Elasticsearch compare two different index

**URL:** <https://discuss.elastic.co/t/elasticsearch-compare-two-different-index/139529>\
**Category:** Elasticsearch\
**Created:** [July 11, 2018, 10:02am UTC](https://discuss.elastic.co/t/elasticsearch-compare-two-different-index/139529 "2018-07-11T10:02:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinu89](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinu89/32/45939_2.png) [@vinu89](https://discuss.elastic.co/u/vinu89)\
**Post date:** [July 11, 2018, 10:02am UTC](https://discuss.elastic.co/t/elasticsearch-compare-two-different-index/139529/1 "2018-07-11T10:02:26Z")

</div>

Hello all,  
I have two different index say index 1 and index 2 I have to find out whether the field which is present in index 2 is also in index 1 say for e.g index 1 has a field called domainname:xyz.com and index 2 has a field name called dname:xyz.com so i have to find out whether the first index fields contains the values of second index . How to do it? Please guide

Thanks in advance

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [July 13, 2018, 3:10pm UTC](https://discuss.elastic.co/t/elasticsearch-compare-two-different-index/139529/2 "2018-07-13T15:10:27Z")

</div>

I assume the field should have the same value for a document with the same unique id in both indices. I think there is no other way than iterating over all documents that have that field set (e.g. using [scroll](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/search-request-scroll.html) and the [exists query](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/query-dsl-exists-query.html)) and checking the value in the second index.

---

<div class="post-metadata">

**Author:** ![vinu89](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinu89/32/45939_2.png) [@vinu89](https://discuss.elastic.co/u/vinu89)\
**Post date:** [July 18, 2018, 3:56am UTC](https://discuss.elastic.co/t/elasticsearch-compare-two-different-index/139529/3 "2018-07-18T03:56:46Z")

</div>

Thanks christoph will check.

---

<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:** [August 15, 2018, 3:56am UTC](https://discuss.elastic.co/t/elasticsearch-compare-two-different-index/139529/4 "2018-08-15T03:56:47Z")

</div>

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