# Update null\_value property

**URL:** <https://discuss.elastic.co/t/update-null-value-property/152674>\
**Category:** Elasticsearch\
**Created:** [October 16, 2018, 1:57pm UTC](https://discuss.elastic.co/t/update-null-value-property/152674 "2018-10-16T13:57:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomTom](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tomtom/32/3676_2.png) [@TomTom](https://discuss.elastic.co/u/TomTom)\
**Post date:** [October 16, 2018, 1:57pm UTC](https://discuss.elastic.co/t/update-null-value-property/152674/1 "2018-10-16T13:57:17Z")

</div>

I created a new property in my mapping, with the following characteristics.

```
{
  "allow_to_buy": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "null_value": "N",
        "ignore_above": 256
      }
    }
  }
}

```

To update the documents I used the function update by query.

```
http://localhost:9200/twitter/tweet/_update_by_query

http://localhost:9200/twitter/tweet/_update_by_query?conflicts=proceed

```

However, even looking for the new property when the value is N, nothing returns.

```
{
    "size": 1000,
    "query": {
        "term": {
            "allow_to_buy.keyword": {
                "value": "N",
                "boost": 1.0
            }
        }
    }
}

```

What should I do?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 17, 2018, 7:23am UTC](https://discuss.elastic.co/t/update-null-value-property/152674/2 "2018-10-17T07:23:23Z")

</div>

can you show a sample document? The `null_value` feature only works, if the field is part of your JSON but explicitely marked as `null`, i.e. `foo: null` - if the field does not exist, than this will not work. You would need to write a small script in the update by query call, that checks for the existence of the field and sets this field by default.

---

<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:** [November 14, 2018, 7:23am UTC](https://discuss.elastic.co/t/update-null-value-property/152674/3 "2018-11-14T07:23:24Z")

</div>

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