# Java High level rest client update

**URL:** <https://discuss.elastic.co/t/java-high-level-rest-client-update/144158>\
**Category:** Elasticsearch\
**Created:** [August 13, 2018, 11:25am UTC](https://discuss.elastic.co/t/java-high-level-rest-client-update/144158 "2018-08-13T11:25:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![darsan55](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@darsan55](https://discuss.elastic.co/u/darsan55)\
**Post date:** [August 13, 2018, 11:25am UTC](https://discuss.elastic.co/t/java-high-level-rest-client-update/144158/1 "2018-08-13T11:25:08Z")

</div>

Hi All,

I m trying to **_update a nested field_** using _java high level client_ .  
Here i am using _script_ to update the document . While executing it its throwing error which i have mentioned below.

**_CODE :_**

```
                    RestHighLevelClient esClient = new RestHighLevelClient(
			  RestClient.builder(new HttpHost("localhost",9200)));

                    UpdateRequest updateRequest = new UpdateRequest("my_index", "_doc", "1");
		
		Map<String, Object> parameters = new HashMap<String, Object>();
		
		parameters.put("key", "value or any java pojo");

		Script inline = new Script(ScriptType.INLINE, "painless",
		        "ctx._source.notes.add(params.key)", parameters);  
		updateRequest.script(inline);
		
		UpdateResponse updateResponse = esClient.update(updateRequest);
		
		System.out.println("results : "+updateResponse.getId());
		
		esClient.close();

```

ERROR :

```
            ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=object mapping for [notes] tried to parse field [null] as object, but found a concrete value]]
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:653)
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:628)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:535)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:508)
at org.elasticsearch.client.RestHighLevelClient.update(RestHighLevelClient.java:366)
at javasparkes.javaapi.JavaApi.main(JavaApi.java:59)
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host[http://localhost:9200], URI [/my_index/_doc/1/_update?timeout=1m], status line [HTTP/1.1 400 Bad Request] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"object mapping for [notes] tried to parse field [null] as object, but found a concrete value"}],"type":"mapper_parsing_exception","reason":"object mapping for [notes] tried to parse field [null] as object, but found a concrete value"},"status":400}
	at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:705)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:198)
	at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:522)
	... 3 more

```

Anyone tried already/ facing the same issue. Please help , have been trying since three days but no solution till now.

Thank you all.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [August 17, 2018, 9:20am UTC](https://discuss.elastic.co/t/java-high-level-rest-client-update/144158/2 "2018-08-17T09:20:16Z")

</div>

Have you tried running the same request using curl to understand whether it's a client issue or your request has something wrong in it?

---

<div class="post-metadata">

**Author:** ![darsan55](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@darsan55](https://discuss.elastic.co/u/darsan55)\
**Post date:** [August 17, 2018, 6:24pm UTC](https://discuss.elastic.co/t/java-high-level-rest-client-update/144158/3 "2018-08-17T18:24:24Z")

</div>

Thanks for the response.  
Yeah I have tried using Kibana. It's working fine.

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [August 20, 2018, 8:14am UTC](https://discuss.elastic.co/t/java-high-level-rest-client-update/144158/4 "2018-08-20T08:14:56Z")

</div>

cool can you please post the json request?

---

<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:** [September 17, 2018, 8:15am UTC](https://discuss.elastic.co/t/java-high-level-rest-client-update/144158/5 "2018-09-17T08:15:09Z")

</div>

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