Description
When writing a dictionary through the Update (with the document as Upsert; see below), all the values in the dictionary are not serialized and therefore not stored/updated on the document.
Consider:
Dictionary<string, string> test = new Dictionary<string, string>() {
{ "abc", null },
{ "def", "ghi" },
};
IUpdateResponse resp = client.Update<Dictionary<string, string>>(
ud => ud
.Type(DocumentType)
.Id("test")
.Doc(test)
.DocAsUpsert(true));
This results in the following request body:
{
"doc_as_upsert": true,
"doc": {
"def": "ghi"
}
}
i.e. the abc=null entry is missing. Also, setting the NullValueHandling property of the JsonSerializerSettings (through the SetJsonSerializerSettingsModifier method of the ConnectionSettings) doesn't fix this problem since it appears that the settings are only applied to the high-level request envelope, but not to the document. This basically seems to make it impossible to clear properties which were previsouly set without using scripts ...