1

We are using the Java library for Elastic Search version 6.8. We are trying to send an UpdateRequest to do partial updates to our fields. A couple of our fields are Objects (-> maps: key, value)

When sending a request for example:

    var updateRequest = new UpdateRequest();
    updateRequest.index(...);
    updateRequest.type(...);
    updateRequest.id(...);

    Map<String, List<String>> mapWithEntries = Map.of("Main", List.of("test@test.com"));

    XContentBuilder content = jsonBuilder()
            .startObject()
            .field("emails", mapWithEntries)
            .endObject();

    updateRequest.doc(content);
    updateRequest.fetchSource(true);
    updateRequest.docAsUpsert(false);
    return updateRequest;

We notice that our new "mapWithEntries" gets merged with the existing map values for the field "emails". Noted that the documentation at update by merging documents does describe this behaviour.

Is it possible to overwrite the existing value for "emails" that only the newly "mapWithEntries" is available? -> updating via script would cause a lot of rework.

JNS
  • 11
  • 4

0 Answers0