# How can I ...Compare two indices fields if data matches then create new index and store the matched data into it

**URL:** <https://discuss.elastic.co/t/how-can-i-compare-two-indices-fields-if-data-matches-then-create-new-index-and-store-the-matched-data-into-it/280130>\
**Category:** Kibana\
**Tags:** elastic-stack-sql, painless, kql-kibana-query-language\
**Created:** [July 31, 2021, 3:51pm UTC](https://discuss.elastic.co/t/how-can-i-compare-two-indices-fields-if-data-matches-then-create-new-index-and-store-the-matched-data-into-it/280130 "2021-07-31T15:51:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sneha\_gupta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sneha_gupta/32/92349_2.png) [@sneha\_gupta](https://discuss.elastic.co/u/sneha_gupta)\
**Post date:** [July 31, 2021, 3:51pm UTC](https://discuss.elastic.co/t/how-can-i-compare-two-indices-fields-if-data-matches-then-create-new-index-and-store-the-matched-data-into-it/280130/1 "2021-07-31T15:51:05Z")

</div>

Was thinking if I can use sub queries either "union" but left with nothing as above is not supported

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [August 3, 2021, 6:49pm UTC](https://discuss.elastic.co/t/how-can-i-compare-two-indices-fields-if-data-matches-then-create-new-index-and-store-the-matched-data-into-it/280130/2 "2021-08-03T18:49:28Z")

</div>

There isn't a builtin way to do this, you'll have to create your own script that does this.

---

<div class="post-metadata">

**Author:** ![sneha\_gupta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sneha_gupta/32/92349_2.png) [@sneha\_gupta](https://discuss.elastic.co/u/sneha_gupta)\
**Post date:** [August 9, 2021, 7:52am UTC](https://discuss.elastic.co/t/how-can-i-compare-two-indices-fields-if-data-matches-then-create-new-index-and-store-the-matched-data-into-it/280130/3 "2021-08-09T07:52:52Z")

</div>

will canvas help me compare two index and draw table accordingly???

---

<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 6, 2021, 7:53am UTC](https://discuss.elastic.co/t/how-can-i-compare-two-indices-fields-if-data-matches-then-create-new-index-and-store-the-matched-data-into-it/280130/4 "2021-09-06T07:53:41Z")

</div>

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