# Elastic Search update api - updating complex data including array objects and parts of document

**URL:** https://discuss.elastic.co/t/elastic-search-update-api-updating-complex-data-including-array-objects-and-parts-of-document/272644
**Category:** Elasticsearch
**Created:** [May 11, 2021, 8:02am UTC](https://discuss.elastic.co/t/elastic-search-update-api-updating-complex-data-including-array-objects-and-parts-of-document/272644 "2021-05-11T08:02:20Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![sagarpatel](https://avatars.discourse-cdn.com/v4/letter/s/ebca7d/32.png) [@sagarpatel](https://discuss.elastic.co/u/sagarpatel)
#### Post date: [May 11, 2021, 9:20am UTC](https://discuss.elastic.co/t/elastic-search-update-api-updating-complex-data-including-array-objects-and-parts-of-document/272644/2 "2021-05-11T09:20:40Z")

</div>

If i understand your question correcttly you want to update array inside the existing document.

There are 2 option:

1. you can send entire new json/document (with updated array) to index and it will replace exsiting document.
2. you can use script with upsert to updating document. Please check official document for [upsert with script](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#scripted_upsert).

Below are some other link which will help you to resolved this:

> <https://stackoverflow.com/questions/32769759/elasticsearch-update-existing-document-by-inserting-elements-to-its-array-field>

> [@Update existing values within a list or array in Elastic Search](https://discuss.elastic.co/t/update-existing-values-within-a-list-or-array-in-elastic-search/18279):
>
> I have a requirement where I need to update(not append) existing values within a list or array in Elastic Search. Is this feature supported in elastic search? For eg: I have a field called jobs as part of my document "jobs": [{ "status": "InProgress", "runId": 1, "start\_date": 2101112, "orderId": "undefined" }, { "status": "InProgress", "runId": 2, "start\_date": 2101112, "orderId": "undefined" },], and I am required to update the orderId for each job run to different values…

---

_[View the full topic](https://discuss.elastic.co/t/elastic-search-update-api-updating-complex-data-including-array-objects-and-parts-of-document/272644)._
