# Changing all array elements in scripted field

**URL:** <https://discuss.elastic.co/t/changing-all-array-elements-in-scripted-field/82246>\
**Category:** Kibana\
**Created:** [April 13, 2017, 5:46am UTC](https://discuss.elastic.co/t/changing-all-array-elements-in-scripted-field/82246 "2017-04-13T05:46:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elad\_sheinfeld](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elad_sheinfeld/32/91900_2.png) [@elad\_sheinfeld](https://discuss.elastic.co/u/elad_sheinfeld)\
**Post date:** [April 13, 2017, 5:46am UTC](https://discuss.elastic.co/t/changing-all-array-elements-in-scripted-field/82246/1 "2017-04-13T05:46:23Z")

</div>

I'm trying to use Kibana's "index patterns" -\> "scripted fields" to manipulate the values of indexed fields.  
When using either of the following script I am getting all the elements copied to the new scripted index:  
doc['EntityTigerDestLong'].values  
also, if I want to change only one value in the array, I can:  
doc['EntityTigerDestLong'].values[0]+1

but I don't know how to change all the values at once.

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [April 13, 2017, 2:31pm UTC](https://discuss.elastic.co/t/changing-all-array-elements-in-scripted-field/82246/2 "2017-04-13T14:31:50Z")

</div>

hi @elad_sheinfeld

seems like you'd have to write a loop to do this.

For a template, see here:  
[https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html#\_accessing\_doc\_values\_from\_painless](https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting-painless.html#_accessing_doc_values_from_painless)

thx,

---

<div class="post-metadata">

**Author:** ![elad\_sheinfeld](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elad_sheinfeld/32/91900_2.png) [@elad\_sheinfeld](https://discuss.elastic.co/u/elad_sheinfeld)\
**Post date:** [April 17, 2017, 10:33pm UTC](https://discuss.elastic.co/t/changing-all-array-elements-in-scripted-field/82246/3 "2017-04-17T22:33:32Z")

</div>

Yep, that solved it !  
thanks

---

<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:** [May 15, 2017, 10:43pm UTC](https://discuss.elastic.co/t/changing-all-array-elements-in-scripted-field/82246/4 "2017-05-15T22:43:13Z")

</div>

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