# Add or update to a exists json in elastic search

**URL:** https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445
**Category:** Elasticsearch
**Created:** [February 8, 2020, 4:29pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445 "2020-02-08T16:29:43Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)
#### Post date: [February 8, 2020, 4:29pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/1 "2020-02-08T16:29:43Z")

</div>

How can I update/add data in ES

for example

{  
appName:test,  
notes:test notes,  
bulkData:[  
{  
id:345345,  
name:test,  
data:[  
{temp:1},  
{temp;2}  
]  
}  
]  
}

now I want to add a few more data on bulkData(key), and also later want to add few more data on bulkData.data(key),  
how can I achieve this without deleting the existing index

Thanks in advance

---

<div class="post-metadata">

### Author: ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)
#### Post date: [February 10, 2020, 1:47pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/2 "2020-02-10T13:47:21Z")

</div>

Hi @dadoonet  
can you please help me on this

---

<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: [February 10, 2020, 2:04pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/3 "2020-02-10T14:04:00Z")

</div>

```auto
PUT index/_doc/1
{
  appName:test,
  notes:test notes,
  bulkData:[
  {
    id:345345,
    name:test,
    data:[
      {temp:1},
      {temp:2}
    ]
  }
  ]
}

```

Then

```auto
PUT index/_doc/1
{
  appName:test,
  notes:test notes,
  bulkData:[
  {
    id:345345,
    name:test,
    data:[
      {temp:1},
      {temp:2},
      {temp:3}
    ]
  }
  ]
}

```

---

<div class="post-metadata">

### Author: ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)
#### Post date: [February 11, 2020, 9:35am UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/4 "2020-02-11T09:35:13Z")

</div>

Thanks @dadoonet

instead of carrying all the data, is there any possibility to push/update to specific key without carrying all the data

---

<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: [February 11, 2020, 10:00am UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/5 "2020-02-11T10:00:54Z")

</div>

May be. With the update API. But I don't really recommend using it. Behind the scene, it will do anyway the same thing.  
IMHO update by query is useful if you have very very big JSON documents to update and you want to limit the bandwidth usage.

Are your documents so big?

---

<div class="post-metadata">

### Author: ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)
#### Post date: [February 11, 2020, 10:51am UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/6 "2020-02-11T10:51:51Z")

</div>

yes, its too large and even the ES API throwing an error with code 413, entity is too large

---

<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: [February 11, 2020, 11:13am UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/7 "2020-02-11T11:13:33Z")

</div>

Could you share a typical document?

I'm just wondering if you designed your documents in the best way.

---

<div class="post-metadata">

### Author: ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)
#### Post date: [February 11, 2020, 1:54pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/8 "2020-02-11T13:54:29Z")

</div>

Below is the doc

```
   {
  "appName": "test",
  "notes": "test notes",
  "bulkData": [
    {
      "id": 345345,
      "name": "test",
      "data": [
        {
          "temp": 1
        },
        {
          "temp": 2
        }
      ]
    },
    {
      "id": 345345345435345,
      "name": "test",
      "data": [
        {
          "temp": 13453
        },
        {
          "temp": 2345
        },
        {
          "temp": 34534543513453
        },
        {
          "temp": 345436565675672300
        }
      ]
    }
  ]
}

```

and mappings

```
    {
    	"myindex": {
    		"mappings": {
    			"bulkUpsertData": {
    				"properties": {
    					"appName": {
    						"type": "text",
    						"fields": {
    							"keyword": {
    								"type": "keyword",
    								"ignore_above": 256
    							}
    						}
    					},
    					"notes": {
    						"type": "text",
    						"fields": {
    							"keyword": {
    								"type": "keyword",
    								"ignore_above": 256
    							}
    						}
    					},
    					"bulkData": {
    						"properties": {
    							"id": {
    								"type": "text",
    								"fields": {
    									"keyword": {
    										"type": "keyword",
    										"ignore_above": 256
    									}
    								}
    							},
    							"name": {
    								"type": "text",
    								"fields": {
    									"keyword": {
    										"type": "keyword",
    										"ignore_above": 256
    									}
    								}
    							},
    							"data": {
    								"properties": {
    									"temp": {
    										"type": "long"
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    	}
    }
```

---

<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: [February 11, 2020, 5:41pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/9 "2020-02-11T17:41:13Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.  
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.  
Please update your post.

---

<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: [February 11, 2020, 5:41pm UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/10 "2020-02-11T17:41:52Z")

</div>

Your document is not big enough to justify using the update API IMO.

---

<div class="post-metadata">

### Author: ![dkishore](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dkishore/32/58054_2.png) [@dkishore](https://discuss.elastic.co/u/dkishore)
#### Post date: [February 12, 2020, 7:53am UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/11 "2020-02-12T07:53:06Z")

</div>

updated/formatted the JSON

---

<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: [March 11, 2020, 7:53am UTC](https://discuss.elastic.co/t/add-or-update-to-a-exists-json-in-elastic-search/218445/12 "2020-03-11T07:53:09Z")

</div>

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