Describe the issue:
Hi we are using Bulk API to update multiple documents at the same time.
We have following Schema Classes in .Net. I have removed some non required fields. we are using Newtonsoft.Json
[OpenSearchType(IdProperty = "id", RelationName = "instant_offer")]
public class InstantOfferDetailDto
{
/// <summary>
/// Nullable Instant offer id because it can be null when clone and assign offer
/// </summary>
[Number(Name = "id")]
public long? Id { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Include)]
[Object(Name = "offer")]
public OfferDetailDto Offer { get; set; }
}
public class OfferDetailDto
{
[JsonProperty(NullValueHandling = NullValueHandling.Include)]
[Date(Name = "assign_date")]
public DateTime? AssignDate { get; set; }
}
Configuration:
While using Bulk API we checked that Null Values are passed to Bulk API request, but it seems API does not update value to null and keep as it is. I checked DebugInformation and that assign_date did not exist in that request.
Do you know how can I set null value to Datetime property thought it is Nullable in c#?
var connectionSettings = new ConnectionSettings(node)
.PrettyJson()
.DisableDirectStreaming()
.RequestTimeout(TimeSpan.FromMinutes(2)).DefaultIndex(indexName);
@SagarViradiya If you’re wanting to use Newtonsoft.Json, you’ll need to take a dependency on OpenSearch.Client.JsonNetSerializer and configure the client to use it like so:
new ConnectionSettings(pool, JsonNetSerializer.Default)
// OR, if you want the behaviour of ignoring nulls except when specified:
new ConnectionSettings(pool, (b, v) => new JsonNetSerializer(b, v, () => new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }))
It seems working. But do you know if it is somewhere documented and have Test case in OpenSearch Library documentation? because I think it is common issue.