# How to drop a nested field that has an empty value?

**URL:** <https://discuss.elastic.co/t/how-to-drop-a-nested-field-that-has-an-empty-value/225649>\
**Category:** Logstash\
**Created:** [March 30, 2020, 9:54am UTC](https://discuss.elastic.co/t/how-to-drop-a-nested-field-that-has-an-empty-value/225649 "2020-03-30T09:54:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robo/32/38295_2.png) [@Robo](https://discuss.elastic.co/u/Robo)\
**Post date:** [March 30, 2020, 9:54am UTC](https://discuss.elastic.co/t/how-to-drop-a-nested-field-that-has-an-empty-value/225649/1 "2020-03-30T09:54:40Z")

</div>

it's possible to drop a nested field in case the value is empty?  
example:  
`"log":{"business_information":""}`

**background:**  
this is a workaround to avoid mapping issues, as other application logs are creating fields like:  
`log.business_information.id`  
`log.business_information.trace`

log.business\_information is mapped as an object. In case an event with empty value will appear, this event is lost due mapping conflict:  
`object mapping for [log.business_information] tried to parse field [business_information] as object, but found a concrete value"`

---

<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:** [March 30, 2020, 3:06pm UTC](https://discuss.elastic.co/t/how-to-drop-a-nested-field-that-has-an-empty-value/225649/2 "2020-03-30T15:06:51Z")

</div>

I have not tested it but I would expect

```
if [log][business_information] == "" { drop {} }

```

to work.

---

<div class="post-metadata">

**Author:** ![Robo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robo/32/38295_2.png) [@Robo](https://discuss.elastic.co/u/Robo)\
**Post date:** [March 31, 2020, 7:57am UTC](https://discuss.elastic.co/t/how-to-drop-a-nested-field-that-has-an-empty-value/225649/3 "2020-03-31T07:57:11Z")

</div>

Thanks for the hint.  
We ended up with this configuration:

> if [log][business\_information] =~ /.\*/ {  
> mutate {  
> rename =\> ["[log][business\_information]", "[log][business\_information\_text]"]  
> }

and in second step the new field is deleted, in case it's empty.

---

<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:** [April 28, 2020, 7:57am UTC](https://discuss.elastic.co/t/how-to-drop-a-nested-field-that-has-an-empty-value/225649/4 "2020-04-28T07:57:15Z")

</div>

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