I am trying to update a document through Java Update API.
I am using UpdateRequest
to send a request for update.
UpdateRequest updateRequest = new UpdateRequest(index, type, id).script(
new Script("ctx._source.'Test Status' = newtestStatus", ScriptType.INLINE, null, updateRequestParams));
updateResponse = client.update(updateRequest).get();
GetResult getResult = updateResponse.getGetResult();
if (getResult.isExists() & getResult.getVersion() == updateResponse.getVersion()) {
testStatusUpdated = true;
}
Here, I always get java.lang.NullPointerException
at getResult.isExists()
and this because GetResult getResult = updateResponse.getGetResult();
is null
.
When I checked the result manually, it is getting updated as required. "Test Status": "STOPPED"
in the document.
getResult
is always returned null
due to which I am not able to check programmatically if the document is updated.
Also, is there any other way to check if document is updated?