DAXGRID/typesense-dotnet

Unable to use UpdateDocuments to remove a field from documents

Closed this issue · 2 comments

When changing a collection field type from something like string to integer, the field needs to be emptied / removed on all documents before doing the update. This seems to not be possible because of the _jsonOptionsCamelCaseIgnoreWritingNull that is applied to the query when using typesenseClient.UpdateDocuments.

Doing something like this results in a Bad Request exception because the body json is empty after the JsonSerializerOptions is applied

await typesenseClient.UpdateDocuments("products", "{\"max_temperature\": null}", "*");

Hi @henriksjodahl, thank you for reporting the bug, I'll be busy for the next couple of days, but I'll take a look at it as soon as possible.

// Rune

Hi @henriksjodahl,

I've implemented a new flag for the UpdateDocuments collection named "FullUpdate", set that to true and nullable values will also be parsed in the JSON serializer. (Version 7.17.0).

The reason you're getting bad request is because we do not support string as the document type, either create a new class with only that field (max_temperature) or make a dictionary or dynamic object with it and set the FullUpdate to true, that should fix your problem.