# Update index using json

**URL:** <https://forum.opensearch.org/t/update-index-using-json/11668>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-java\
**Created:** [December 2, 2022, 4:39am UTC](https://forum.opensearch.org/t/update-index-using-json/11668 "2022-12-02T04:39:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Din](https://avatars.discourse-cdn.com/v4/letter/d/ccd318/32.png) [@Din](https://forum.opensearch.org/u/Din)\
**Post date:** [December 2, 2022, 4:39am UTC](https://forum.opensearch.org/t/update-index-using-json/11668/1 "2022-12-02T04:39:24Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
opesearch-rest-high-level-client:2.4.0

**Describe the issue** :  
Is there a way to update part of an existing index with json?  
For eg:  
Current index  
{  
“\_index”: “record\_index”,  
“\_type”: “\_doc”,  
“\_id”: “123456”,  
“\_version”: 1,  
“\_score”: 0,  
“\_source”: {  
“record”: “{\n “uuid”: “123456”,\n “status”: “S”,\n “comments”: “Test record only”}”  
}  
}

update it to  
{  
“\_index”: “record\_index”,  
“\_type”: “\_doc”,  
“\_id”: “123456”,  
“\_version”: 1,  
“\_score”: 0,  
“\_source”: {  
“record”: “XYZ”  
}  
}

where XYZ is a json

something like this  
XContentBuilder jb = XContentFactory.jsonBuilder();  
jb.startObject().field(“record”, XYZ).endObject();

**Configuration** :

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![wbeckler](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@wbeckler](https://forum.opensearch.org/u/wbeckler)\
**Post date:** [December 12, 2022, 4:00pm UTC](https://forum.opensearch.org/t/update-index-using-json/11668/2 "2022-12-12T16:00:26Z")

</div>

I want to point people here to see a discussion on this question:

> <https://github.com/opensearch-project/OpenSearch/issues/5422#issuecomment-1335374201>
>
> \*\*Describe the bug\*\*
> I reported the bug here https://forum.opensearch.org/t/upd…ating-creating-index-using-high-level-java-client/11649
> 
> \*\*To Reproduce\*\*
> Code snipped provided in the link above
> 
> \*\*Expected behavior\*\*
> index should have json instead of string with double quotes
> 
> \*\*Plugins\*\*
> Please list all plugins currently enabled.
> 
> \*\*Screenshots\*\*
> added the sample output in the link
> 
> \*\*Host/Environment (please complete the following information):\*\*
> - OS: Windows and Linux
> - This bug is independent of OS
> 
> \*\*Additional context\*\*
> Add any other context about the problem here.
