Partial update of document through java API


(Rajesh Samala) #1

I am facing issue during partial update of document through java API.

XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().value(objectMapper.writeValueAsString(jsonObject.getDefaultData()));

final Map<String, Object> params = new HashMap<>();

params.put("object_section", xContentBuilder);

final Script inlineUpdateScript = new Script(inlineScriptBuilder.toString(), ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, params, XContentType.JSON);

UpdateResponse updateResponse = inlineUpdateRequest.setScript(inlineUpdateScript).execute()
.actionGet(3000);

Exception:
java.io.IOException: can not write type [class org.elasticsearch.common.xcontent.XContentBuilder]
! at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:610) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.common.io.stream.StreamOutput.lambda$static$10(StreamOutput.java:525) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.common.io.stream.StreamOutput.writeGenericValue(StreamOutput.java:608) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.common.io.stream.StreamOutput.writeMap(StreamOutput.java:414) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.script.Script.writeTo(Script.java:114) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.action.update.UpdateRequest.writeTo(UpdateRequest.java:830) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.transport.TcpTransport.buildMessage(TcpTransport.java:1056) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.transport.TcpTransport.sendRequest(TcpTransport.java:920) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.transport.TransportService.sendRequestInternal(TransportService.java:493) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.transport.TransportService.sendRequest(TransportService.java:459) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.action.TransportActionNodeProxy.execute(TransportActionNodeProxy.java:51) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.client.transport.support.TransportProxyClient.lambda$execute$0(TransportProxyClient.java:63) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:233) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:63) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:326) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80) ~[elasticsearch-5.0.1.jar:5.0.1]
! at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54) ~[elasticsearch-5.0.1.jar:5.0.1]
! at
! Causing: org.elasticsearch.common.util.concurrent.UncategorizedExecutionException: Failed execution


(system) #2

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