You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was able to get this to work using a similar object and implementing JsonpSerializable like so.
@Overridepublicvoidserialize(jakarta.json.stream.JsonGeneratorgenerator, JsonpMappermapper) {
if(generatorinstanceofJacksonJsonpGenerator){
// data is a byte[] containing raw JSON dataStringjson = newString(data, StandardCharsets.UTF_8);
try {
((JacksonJsonpGenerator) generator).jacksonGenerator().writeRawValue(json);
} catch (IOExceptione) {
thrownewIllegalStateException("Unable to write raw json", e);
}
}else{
thrownewUnsupportedOperationException("Only JacksonJsonpGenerator is supported");
}
}
The text was updated successfully, but these errors were encountered:
NavidMitchell
changed the title
Update opeeration does not work with BinaryData object.
Update operation does not work with BinaryData object.
Jul 3, 2023
Hello! The purpose of the BinaryData class is actually to provide a generic class for responses, for example when the server response is not in json format (for some APIs is just text) you can use BinaryData to read it.
JsonData is probably what you were looking for to write json strings into the document field:
JsonData data = JsonData.of("{\"foo\":\"bar\"}", jsonpMapper);
esClient.update(u -> u
...
.doc(data)
, JsonData.class);
However, it makes sense for the client to also accept BinaryData with ContentType.APPLICATION_JSON, we'll add it as an option!
Java API client version
7.17.10
Java version
11
Elasticsearch Version
7.17.9
Problem description
If you try and perform an update when using the BinaryData object the document will be created but it will be empty.
I have created a test for a reproducer.
I was able to get this to work using a similar object and implementing JsonpSerializable like so.
The text was updated successfully, but these errors were encountered: