# Loop through results and update another index

**URL:** <https://discuss.elastic.co/t/loop-through-results-and-update-another-index/243260>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [July 30, 2020, 5:48pm UTC](https://discuss.elastic.co/t/loop-through-results-and-update-another-index/243260 "2020-07-30T17:48:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![msf127](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@msf127](https://discuss.elastic.co/u/msf127)\
**Post date:** [July 30, 2020, 5:48pm UTC](https://discuss.elastic.co/t/loop-through-results-and-update-another-index/243260/1 "2020-07-30T17:48:06Z")

</div>

Is it possible to loop through the results of a query and update (add a scripted field in) another index based on data within the result set?

Another way to think about this is updating an index with a lookup value from another index.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 30, 2020, 6:31pm UTC](https://discuss.elastic.co/t/loop-through-results-and-update-another-index/243260/2 "2020-07-30T18:31:15Z")

</div>

You might be able to reindex through an ingest pipeline with an [enrich processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest-enriching-data.html)?

---

<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 27, 2020, 6:31pm UTC](https://discuss.elastic.co/t/loop-through-results-and-update-another-index/243260/3 "2020-08-27T18:31:19Z")

</div>

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