# Python - Update nested object

**URL:** <https://discuss.elastic.co/t/python-update-nested-object/94875>\
**Category:** Elasticsearch\
**Created:** [July 27, 2017, 10:50pm UTC](https://discuss.elastic.co/t/python-update-nested-object/94875 "2017-07-27T22:50:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Achi](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@Achi](https://discuss.elastic.co/u/Achi)\
**Post date:** [July 27, 2017, 10:50pm UTC](https://discuss.elastic.co/t/python-update-nested-object/94875/1 "2017-07-27T22:50:46Z")

</div>

Hello,

I would like to use a Nested file for comments, but I can't find a way to update it as soon as someone post a comment.

Here is my mapping (using elasticsearch-dsl)

```
m = Mapping('comments'')

comments = Nested()
comments.field('author', Text())
comments.field('comment'', Text())
m.field('comments', comments)

m.save('search')

```

Now if I want to add a comment, it doesn't work:

```
es = Elasticsearch()
updated=es.update(index="search", doc_type="comments", id=43, body=
                       {
                        "script" : "ctx._source.comments.add(params.action)",
                        "params" :
                                { "action": {"author":"Antoine", "comment": "Hello"}
                                }
                       }) 

```

Is it the good way to do that ?

Thanks a lot!

---

<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 24, 2017, 10:50pm UTC](https://discuss.elastic.co/t/python-update-nested-object/94875/2 "2017-08-24T22:50:54Z")

</div>

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