# Change "null" to null value

**URL:** <https://discuss.elastic.co/t/change-null-to-null-value/137855>\
**Category:** Logstash\
**Created:** [June 28, 2018, 8:27pm UTC](https://discuss.elastic.co/t/change-null-to-null-value/137855 "2018-06-28T20:27:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lelwar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lelwar/32/45040_2.png) [@lelwar](https://discuss.elastic.co/u/lelwar)\
**Post date:** [June 28, 2018, 8:27pm UTC](https://discuss.elastic.co/t/change-null-to-null-value/137855/1 "2018-06-28T20:27:58Z")

</div>

Hello,  
I have an application that sends through the rest API a Json to logstash and this is filtered and outputted to an Elasticsearch cluster. The json is nested, so I have flattened it using the "split" codec in logstash like the following:

```
mutate {
	  add_field => { "primary_nested" => "%{[primary][nested]}" }
}

```

It works well, but when the nested field is empty (null) the value given to a field will be the string: "%{[primary][nested]}" because it finds no value. Is there a way to filter it so that if the value comes as "null" it leaves it empty so that Elasticsearch can receive it as null?

regards,

Israel

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [July 2, 2018, 3:34pm UTC](https://discuss.elastic.co/t/change-null-to-null-value/137855/2 "2018-07-02T15:34:19Z")

</div>

Wrap it in this?

```
if [primary][nested] {
...
}
```

---

<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:** [July 30, 2018, 3:34pm UTC](https://discuss.elastic.co/t/change-null-to-null-value/137855/3 "2018-07-30T15:34:21Z")

</div>

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