# Null Values Ignred by Elasticsearch

**URL:** <https://discuss.elastic.co/t/null-values-ignred-by-elasticsearch/298456>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 1, 2022, 12:07am UTC](https://discuss.elastic.co/t/null-values-ignred-by-elasticsearch/298456 "2022-03-01T00:07:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xef](https://avatars.discourse-cdn.com/v4/letter/x/898d66/32.png) [@xef](https://discuss.elastic.co/u/xef)\
**Post date:** [March 1, 2022, 12:07am UTC](https://discuss.elastic.co/t/null-values-ignred-by-elasticsearch/298456/1 "2022-03-01T00:07:15Z")

</div>

We are using the NEST library with Elasticsearch versions 7.14.  
Lets say we have assigned a field a value of "hello World".  
The filed is mapped as a Keyword type and Not Indexed.

If you update that document using the Update API with the same field having a null value, Elasticsearch ignores that assignement and keeps what was originally there i.e. "Hello World". In order to get rid of the fields value you have to assign it something like an empty string which classes in .NET with string properties normally have a default value of NULL.

So when a user updates a field by removing its value in the UI, the index does not take that change and keeps the old value.

So you actually have a completely different data in the index than what you think you have after an update.

---

<div class="post-metadata">

**Author:** ![hendry.lim](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendry.lim/32/71328_2.png) [@hendry.lim](https://discuss.elastic.co/u/hendry.lim)\
**Post date:** [March 1, 2022, 12:13am UTC](https://discuss.elastic.co/t/null-values-ignred-by-elasticsearch/298456/2 "2022-03-01T00:13:08Z")

</div>

You should remove the field from the document in Elasticsearch, instead of setting it to `null`.

---

<div class="post-metadata">

**Author:** ![xef](https://avatars.discourse-cdn.com/v4/letter/x/898d66/32.png) [@xef](https://discuss.elastic.co/u/xef)\
**Post date:** [March 1, 2022, 11:44am UTC](https://discuss.elastic.co/t/null-values-ignred-by-elasticsearch/298456/3 "2022-03-01T11:44:43Z")

</div>

Hi  
But we need that field for other documents where the value is not null. And even that record itself may have an actual value in the future. It has to stay in the mapping and the index.  
Is this behavior of rejecting null values in an existing field correct? As I mentioned, users who remove the value in the UI, the update fails leaving inconsistent data.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 29, 2022, 11:45am UTC](https://discuss.elastic.co/t/null-values-ignred-by-elasticsearch/298456/4 "2022-03-29T11:45:16Z")

</div>

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