# Isuue while overriding JSON object in document

**URL:** <https://discuss.elastic.co/t/isuue-while-overriding-json-object-in-document/266239>\
**Category:** Elasticsearch\
**Created:** [March 4, 2021, 12:43pm UTC](https://discuss.elastic.co/t/isuue-while-overriding-json-object-in-document/266239 "2021-03-04T12:43:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pawar.pradeep85](https://avatars.discourse-cdn.com/v4/letter/p/a3d4f5/32.png) [@pawar.pradeep85](https://discuss.elastic.co/u/pawar.pradeep85)\
**Post date:** [March 4, 2021, 12:43pm UTC](https://discuss.elastic.co/t/isuue-while-overriding-json-object-in-document/266239/1 "2021-03-04T12:43:40Z")

</div>

Hello,

I want to perform a task which requires below activities:

1. Override "xyz" record with the new "xyz" record completely (avoid update/merging) in the existing document.
2. New "xyz" record structure could be different. Therefore I am preferring to override it with its key name.

I used "new IndexRequest(indexName).id(docId).source(sourceMap, XContentType.JSON)", with below combination:

- When tried to pass "xyz" as JSONObject got error "cannot write xcontent for unknown value of type class org.json.JSONObject"

- When tried to pass "xyz" as JsonString got error "tried to parse field [xyz] as object, but found a concrete value"

- When tried to pass "xyz" as JsonBytes got error "tried to parse field [xyz] as object, but found a concrete value"

- When tried to pass "xyz" as DTO got error "tried to parse field [xyz] as object, but found a concrete value"

Could someone please assist me in this?

Thanks,  
Pradeep Pawar

---

<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:** [April 1, 2021, 12:44pm UTC](https://discuss.elastic.co/t/isuue-while-overriding-json-object-in-document/266239/2 "2021-04-01T12:44:35Z")

</div>

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