In Update action using java API client when i set few fields of java object and pass the other fields get updated to null in Elasticsearch, and i am not sure how this happens as while sending the object i only set few fields
Product remoteClientOperationDocument = new Product();
remoteClientOperationDocument.setId(remoteClientOperation.getId());
if (remoteClientOperation.getRequestId() != null)
remoteClientOperationDocument.setRequestId(remoteClientOperation.getRequestId());
if (remoteClientOperation.getClientId() != null)
remoteClientOperationDocument.setClientId(remoteClientOperation.getClientId());
if (remoteClientOperation.getRemoteClientOperationType() != null)
remoteClientOperationDocument.setRemoteClientOperationType(remoteClientOperation.getRemoteClientOperationType());
if (remoteClientOperation.getRequestTime() != null)
remoteClientOperationDocument.setRequestTime(remoteClientOperation.getRequestTime());
if (remoteClientOperation.getResponseTime() != null)
remoteClientOperationDocument.setResponseTime(remoteClientOperation.getResponseTime());
if (remoteClientOperation.getResponseText() != null)
remoteClientOperationDocument.setResponseText(remoteClientOperation.getResponseText());
then pass this to action
UpdateOperation<Product, Product> updateOperation = new UpdateOperation.Builder<Product, Product>()
.id(client.getId())
.index(PRODUCT)
.action(a -> a.doc(client).docAsUpsert(true))
.build();
and then elasticsearchclient.bulk(new BulkOperation.Builder().update(updateOperation).build());
but after this the fields that i did not set get updated with null, so i think issue is when i create new Product(); all fields are initialized with null but then how can i create partial document for elasticsearch using java