# How to append new document to a nested field?

**URL:** https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175
**Category:** Elasticsearch
**Created:** [August 8, 2017, 3:58am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175 "2017-08-08T03:58:41Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Red](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Red](https://discuss.elastic.co/u/Red)
#### Post date: [August 8, 2017, 3:58am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/1 "2017-08-08T03:58:41Z")

</div>

how to append new document to a nested field?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 8, 2017, 5:02am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/2 "2017-08-08T05:02:00Z")

</div>

An example?

---

<div class="post-metadata">

### Author: ![Red](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Red](https://discuss.elastic.co/u/Red)
#### Post date: [August 8, 2017, 6:12am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/4 "2017-08-08T06:12:14Z")

</div>

Red1m  
does this question need an example?

any nested fields.

```
{
      "nested_field":[
         {"id":1},
         {"id":2}
      ]
}

```

then, i want to add “id”:3 to the nested\_field, how?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 8, 2017, 6:36am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/5 "2017-08-08T06:36:04Z")

</div>

```auto
PUT index/doc/1
{
      "nested_field":[
         {"id":1},
         {"id":2},
         {"id":3}
      ]
}

```

---

<div class="post-metadata">

### Author: ![Red](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Red](https://discuss.elastic.co/u/Red)
#### Post date: [August 8, 2017, 6:43am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/6 "2017-08-08T06:43:05Z")

</div>

is there any way appending object to the end?  
not the way recreate the field.  
this will cost a lot when the field is very large.

how about using script which loads all data then restore to the field with new data.  
may this reduce the cost of network transmit?

and creating one field one time a day is acceptable

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 8, 2017, 7:07am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/7 "2017-08-08T07:07:00Z")

</div>

The update API does that: [https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-update.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-update.html)

---

<div class="post-metadata">

### Author: ![Red](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Red](https://discuss.elastic.co/u/Red)
#### Post date: [August 8, 2017, 7:15am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/8 "2017-08-08T07:15:00Z")

</div>

thank for your patience.  
my English is bad

---

<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 5, 2017, 7:15am UTC](https://discuss.elastic.co/t/how-to-append-new-document-to-a-nested-field/96175/9 "2017-09-05T07:15:03Z")

</div>

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