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.