# Inline script to update a list items based on a condition

**URL:** <https://discuss.elastic.co/t/inline-script-to-update-a-list-items-based-on-a-condition/78969>\
**Category:** Elasticsearch\
**Created:** [March 17, 2017, 6:51am UTC](https://discuss.elastic.co/t/inline-script-to-update-a-list-items-based-on-a-condition/78969 "2017-03-17T06:51:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![muthucse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muthucse/32/45217_2.png) [@muthucse](https://discuss.elastic.co/u/muthucse)\
**Post date:** [March 17, 2017, 6:51am UTC](https://discuss.elastic.co/t/inline-script-to-update-a-list-items-based-on-a-condition/78969/1 "2017-03-17T06:51:28Z")

</div>

I need an inline script to iterate over the array of countries and check if the country\_name matches ex: US. Then update the field of that obj.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 20, 2017, 9:35am UTC](https://discuss.elastic.co/t/inline-script-to-update-a-list-items-based-on-a-condition/78969/2 "2017-03-20T09:35:34Z")

</div>

Hey,

can you please provide more and better information, instead of just stating a very blurry requirement. Explain, what you already tried, where you failed (including index creation, sample documents, query execution, **everything** that is needed to reproduce), which problems you ran into, why you think that you need an inline script to iterate of countries instead of just executing a search. Maybe you could use the [update by query](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/docs-update-by-query.html) functionality - but with this sentence you make it impossible for others to chime in and help.

Please take your time and come up with a fully written problem, your tries and the issues with those. Just asking for a solution for your exactly tailored problem without specifying first is a reason to ignore suchs posts for many readers.

--Alex

---

<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 17, 2017, 9:35am UTC](https://discuss.elastic.co/t/inline-script-to-update-a-list-items-based-on-a-condition/78969/3 "2017-04-17T09:35:46Z")

</div>

Closed on April 17, 2017, 9:35am UTC

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