I attempted to add a couple new fields to an existing record in elastic search. The record is being updated, however all previously indexed fields have been cleared.
Is there something am I doing wrong?
Maven dependency
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.7.1</version>
</dependency>
Me code:
RestClientBuilder builder = RestClient.builder(new HttpHost(esIP, Integer.parseInt(esPort)));
RestClient restClient = builder.build();
//jsonMap indecates one record to be indexed
br.operations(op -> op.index(idx -> idx.index((String) jsonMap.get("index_name")).id(jsonMap.get("id").toString()).document(jsonMap)));
Try following, you shoud exclude meta data (like index, id) from doc param.