# Add or update a new item into the nested objects

**URL:** <https://discuss.elastic.co/t/add-or-update-a-new-item-into-the-nested-objects/138360>\
**Category:** Elasticsearch\
**Created:** [July 3, 2018, 11:09am UTC](https://discuss.elastic.co/t/add-or-update-a-new-item-into-the-nested-objects/138360 "2018-07-03T11:09:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![magorbe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magorbe/32/36871_2.png) [@magorbe](https://discuss.elastic.co/u/magorbe)\
**Post date:** [July 3, 2018, 11:09am UTC](https://discuss.elastic.co/t/add-or-update-a-new-item-into-the-nested-objects/138360/1 "2018-07-03T11:09:50Z")

</div>

I have the next mapping :

```
"c_index": {
    "aliases": {},
    "mappings": {
        "an": {
            "properties": {
                "id": {
                    "type": "string"
                },
                "sm": {
                    "type": "nested",
                    "properties": {
                        "cr": {
                            "type": "nested",
                            "properties": {
                                "c": {
                                    "type": "string"
                                },
                                "e": {
                                    "type": "long"
                                },
                                "id": {
                                    "type": "string"
                                },
                                "s": {
                                    "type": "long"
                                }
                            }
                        },
                        "id": {
                            "type": "string"
                        }
                    }
                }
            }
        }
    }

```

I want to insert a new element 'sm' in a specific an (an with id =X), but I can not get all the other sm's that are already inside that an, because they are too bigs and is very difficult to deal with them. Is there any way to do this? if the sm already exists can I update it? I already tried to insert the new element and insert it, but it erases the others that I have. Thank you very much!

---

<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:** [July 31, 2018, 11:17am UTC](https://discuss.elastic.co/t/add-or-update-a-new-item-into-the-nested-objects/138360/2 "2018-07-31T11:17:06Z")

</div>

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