Hello!
This is weird, I have tried this with server version 8.14.0 and java client versions 8.13.3 and the latest 8.14.3, and it works as expected, field2 gets updated to null. Could you give me more information on which client + server versions are you using?
JacksonJsonpMapper mapper = new JacksonJsonpMapper();
mapper.objectMapper().setSerializationInclusion(JsonInclude.Include.ALWAYS);
ElasticsearchTransport transport = new RestClientTransport(
restClient, mapper);
Thank you both for the help, yes the issue was with the default JacksonJsonpMapper, by initializing the JacksonJsonpMapper without passing any ObjectMapper, the default used constructor will build:
public JacksonJsonpMapper() {
this((new ObjectMapper()).configure(SerializationFeature.INDENT_OUTPUT, false).setSerializationInclusion(Include.NON_NULL));
}
which ignores null value in the serialization. I assume you got the code from the official documentation, we'll update it with the recommended way to initialize the mapper.
yup, we are in the process of migrating our code base from high level rest client to the recommended java api client, so for the initialisation purpose we just used the code snippet in the documentation to initialise the client.
but it does makes sense looking back, why until the request is generated, it was having null in the body, but on execution of the request it failed to remove the value from the field.
Any thanks to both of you for the quick help and pointing out where the problem was.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.