# Allowing Date time null value to update in Bulk API using OpenSerch.Net

**URL:** <https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624>\
**Category:** OpenSearch Client Libraries\
**Tags:** opensearch-net\
**Created:** [November 10, 2023, 11:28am UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624 "2023-11-10T11:28:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SagarViradiya](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SagarViradiya](https://forum.opensearch.org/u/SagarViradiya)\
**Post date:** [November 10, 2023, 11:28am UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/1 "2023-11-10T11:28:38Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):  
[OpenSearch.Net](http://OpenSearch.Net) v1.2.0

**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

```csharp
 [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#?

**Relevant Logs or Screenshots** :

---

<div class="post-metadata">

**Author:** ![xtansia](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/xtansia/32/4961_2.png) [@xtansia](https://forum.opensearch.org/u/xtansia)\
**Post date:** [November 23, 2023, 9:53pm UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/2 "2023-11-23T21:53:11Z")

</div>

Hi @SagarViradiya,

Are you able to share your client configuration? As it will help me to debug and reproduce the issue myself more quickly.

---

<div class="post-metadata">

**Author:** ![SagarViradiya](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SagarViradiya](https://forum.opensearch.org/u/SagarViradiya)\
**Post date:** [November 24, 2023, 5:05am UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/3 "2023-11-24T05:05:41Z")

</div>

We are using .Net 4.7.

OpenSearch Connection

```csharp
 var connectionSettings = new ConnectionSettings(node)
                .PrettyJson()
                .DisableDirectStreaming()
                .RequestTimeout(TimeSpan.FromMinutes(2)).DefaultIndex(indexName);

```

Index Schema:

```json
{
  "instant_offer": {
    "mappings": {
      "properties": {
        "id": {
          "type": "long"
        },
        "offer": {
          "properties": {
            "assign_date": {
              "type": "date"
            }
          }
        }
      }
    }
  }
}

```

Let us know other thing you need.

---

<div class="post-metadata">

**Author:** ![xtansia](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/xtansia/32/4961_2.png) [@xtansia](https://forum.opensearch.org/u/xtansia)\
**Post date:** [November 26, 2023, 10:57pm UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/4 "2023-11-26T22:57:26Z")

</div>

@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:

```auto
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 }))

```

---

<div class="post-metadata">

**Author:** ![SagarViradiya](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SagarViradiya](https://forum.opensearch.org/u/SagarViradiya)\
**Post date:** [November 28, 2023, 5:42am UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/5 "2023-11-28T05:42:32Z")

</div>

Ok, I will try out and let you know.

---

<div class="post-metadata">

**Author:** ![SagarViradiya](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SagarViradiya](https://forum.opensearch.org/u/SagarViradiya)\
**Post date:** [November 28, 2023, 10:25am UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/6 "2023-11-28T10:25:31Z")

</div>

> [@xtansia](#):
>
> ```auto
> 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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)\
**Post date:** [January 27, 2024, 10:25am UTC](https://forum.opensearch.org/t/allowing-date-time-null-value-to-update-in-bulk-api-using-openserch-net/16624/7 "2024-01-27T10:25:35Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
