We are using the NEST library with Elasticsearch versions 7.14.
Lets say we have assigned a field Greeting with 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.
var result = client.Update<object>(id, u => u
.Index("services")
.Doc(new
{
Greeting=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.
it will not allow to add null value as it is not indexable in lucene. You can handle null values using specifing null_values attributes in index mapping (it will set default values).
Please check #5152 and comments on #3930 issue for handling null value in NEST. They have gievn example for date field but same will work for keyword field as well.
If you provide NULL as string value with single quotes, it will add NULL as string for specific field. so you are still have string or text value for that specific field and not null value.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.