Java High level rest client update

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.


                    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);  
		UpdateResponse updateResponse =  esClient.update(updateRequest);
		System.out.println("results : "+updateResponse.getId());


            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.client.RestHighLevelClient.parseEntity(
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(
at org.elasticsearch.client.RestHighLevelClient.performRequest(
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(
at org.elasticsearch.client.RestHighLevelClient.update(
at javasparkes.javaapi.JavaApi.main(
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(
	at org.elasticsearch.client.RestClient.performRequest(
	at org.elasticsearch.client.RestClient.performRequest(
	at org.elasticsearch.client.RestHighLevelClient.performRequest(
	... 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.

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?

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

cool can you please post the json request?

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