I'm working with the new Java client, v8.3.3. I'm trying to do the following:
- take a source from a
- create a Jakarta
JsonObjectBuilder from that
- use an
ObjectMapper to convert that
JsonObject into a Java object (
My problem is that when converting from
Foo, string fields that are null on the source (
JsonValue.ValueType.NULL) are being set to String
"null" on the Java object, when they ought to be just set to
Has anyone else encountered anything similar, or know of a way to handle this?
Can you provide a code snippets so that we have more details to reproduce the issue?
Also, you don't need to go from
JsonObject and finally
Foo: you can directly call
someJsonData.to(Foo.class), which will use the object mapper associated to the Elasticsearch client.
I need to add fields (specifically for
_id) to the source, which is why I'm creating a
JsonObjectBuilder first, before converting to
Here's a snippet of what I'm doing:
JsonObjectBuilder sourceBuilder = Json.createObjectBuilder(JsonData.of(item.result().source(), _mapper).toJson().asJsonObject());
sourceBuilder.add("_index", item.result().index()).add("_id", item.result().id());
return _modelMapper.map(sourceBuilder.build(), Foo.class)
For example, if a String field
name on Foo is null in the source, the resulting
Foo object will have name set to
"null", and not just
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.