# Update Nested

**URL:** <https://discuss.elastic.co/t/update-nested/126540>\
**Category:** Elasticsearch\
**Created:** [April 3, 2018, 9:29am UTC](https://discuss.elastic.co/t/update-nested/126540 "2018-04-03T09:29:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [April 3, 2018, 9:29am UTC](https://discuss.elastic.co/t/update-nested/126540/1 "2018-04-03T09:29:25Z")

</div>

Hi,  
I'm using ES 6.2.2.

Could I update a nested object with a new value while keeping the already indexed values?

```
POST /people/_doc/100
{
            "num" : [
             {
              "numero":"789456123",
              "favoris":true
              },
              {
              "numero":"123456798",
              "favoris":false
              }]}

```

The Nested hold two set of value, and I would like to index a third one:

```
POST /people/_doc/100/_update
{
   "script" : {
        "lang": "painless",
        "source": "ctx._source.num =params.new",
        "params" : {
            "new" : [
             {
              "numero":"456789123",
              "favoris": false
              }]}}}

```

But with this syntax the new one replace the previous set.  
Could I put something like :  
`"source":"ctx._source.num =ctx._source.siret && params.new",`  
Or:  
`"source":"ctx._source.num =ctx._source.siret + params.new",` ?

---

<div class="post-metadata">

**Author:** ![Varan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varan/32/32120_2.png) [@Varan](https://discuss.elastic.co/u/Varan)\
**Post date:** [April 4, 2018, 8:08am UTC](https://discuss.elastic.co/t/update-nested/126540/2 "2018-04-04T08:08:09Z")

</div>

I know that ES have to reindex the whole thing each time, but I don't understand how to do it with a nested object when I easily could with a normal field.

---

<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 2, 2018, 8:08am UTC](https://discuss.elastic.co/t/update-nested/126540/3 "2018-05-02T08:08:10Z")

</div>

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