# Adding a copy field and set it lowercase

**URL:** <https://discuss.elastic.co/t/adding-a-copy-field-and-set-it-lowercase/126762>\
**Category:** Logstash\
**Created:** [April 4, 2018, 2:43pm UTC](https://discuss.elastic.co/t/adding-a-copy-field-and-set-it-lowercase/126762 "2018-04-04T14:43:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Pellegrini\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_pellegrini_m/32/26713_2.png) [@Gabriel\_Pellegrini\_M](https://discuss.elastic.co/u/Gabriel_Pellegrini_M)\
**Post date:** [April 4, 2018, 2:43pm UTC](https://discuss.elastic.co/t/adding-a-copy-field-and-set-it-lowercase/126762/1 "2018-04-04T14:43:22Z")

</div>

Hello guys,

I'm having a trouble with a mutate filter, where i need to set a field copy to lowercase.  
But when i try to load on elastic , the field copy won't be lowercase.

My Logstash Version is 5.2

i'm using the configuration below:

```
filter {   
        mutate {
            rename => {"desc_ufe" => "state" }
            rename => {"desc_local" => "city" }
            rename => {"desc_bairro" => "neighborhood" }
            rename => {"desc_lograd" => "streetName" }
            rename => {"desc_cep" => "postalCode" }
            rename => {"desc_lograd_complemento" => "supplement" }
            rename => {"cod_mun" => "IBGEcode" }
            
            convert => {"IBGEcode" => "string"}
            
            add_field => {"statecp" => "%{state}"}
            add_field => {"citycp" => "%{city}"}
            add_field => {"neighborhoodcp" => "%{neighborhood}"}
            add_field => {"streetNamecp" => "%{streetName}"}
            add_field => {"supplementcp" => "%{supplement}"}

            lowercase => ["statecp","citycp","neighborhoodcp","streetNamecp","supplementcp"]
        }
     }

```

Thank you for any help.

---

<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:** [April 4, 2018, 3:05pm UTC](https://discuss.elastic.co/t/adding-a-copy-field-and-set-it-lowercase/126762/2 "2018-04-04T15:05:35Z")

</div>

Split the lowercase into a separate mutate filter. mutate does operations in a fixed order and it is doing the lowercase before those fields have been created.

---

<div class="post-metadata">

**Author:** ![Gabriel\_Pellegrini\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_pellegrini_m/32/26713_2.png) [@Gabriel\_Pellegrini\_M](https://discuss.elastic.co/u/Gabriel_Pellegrini_M)\
**Post date:** [April 4, 2018, 5:38pm UTC](https://discuss.elastic.co/t/adding-a-copy-field-and-set-it-lowercase/126762/3 "2018-04-04T17:38:29Z")

</div>

Thank you Badger , it worked as should.

---

<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:** [May 2, 2018, 5:38pm UTC](https://discuss.elastic.co/t/adding-a-copy-field-and-set-it-lowercase/126762/4 "2018-05-02T17:38:44Z")

</div>

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