-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Elastic.Clients.Elasticsearch version: 9.1.4
Elasticsearch version: 9.0.7
Description:
I'm currently migrating from the old Nest package to the new elasticsearch package, however the serialiser behaviour seems to have flipped... Before, it seemed that the Nest serialiser would include null values, unless they weren't specifically set in the model to null, then it would ignore them.
With the new elasticsearch package, the serialiser seems to be ignoring null values by default. This is causing issues when updating a record with a null value, as the update will be ignored...
I can flip the behaviour back in the client serialiser global settings:
options.DefaultIgnoreCondition = JsonIgnoreCondition.Never;
However, this is causing issues around the elastic security models such as: IndicesPrivileges as the model includes a query model with a large amount of fields. We don't set most of them, but as null isn't ignored the request is failing as some of those fields cannot be null. As this isn't our model we cannot add [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] to these fields...
Alternatively, I could leave the serialiser as it is, and add [JsonIgnore(Condition = JsonIgnoreCondition.Never)] to almost every field in each model we have. I believe that this would work, however it feels quite drastic and not the intended method. I wanted to check if there is a simpler approach that I am missing, this worked well with the Nest client so I would be surprised if that previous behaviour had been scrapped.
Thanks !