# How to ignore fields is null when I combine them?

**URL:** <https://discuss.elastic.co/t/how-to-ignore-fields-is-null-when-i-combine-them/83235>\
**Category:** Logstash\
**Created:** [April 21, 2017, 5:12pm UTC](https://discuss.elastic.co/t/how-to-ignore-fields-is-null-when-i-combine-them/83235 "2017-04-21T17:12:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chianingwang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chianingwang/32/28037_2.png) [@chianingwang](https://discuss.elastic.co/u/chianingwang)\
**Post date:** [April 21, 2017, 5:12pm UTC](https://discuss.elastic.co/t/how-to-ignore-fields-is-null-when-i-combine-them/83235/1 "2017-04-21T17:12:07Z")

</div>

This is my grok pattern

add\_field =\> {  
if [referer\_url] == "-"  
"referer" =\> "%{referer\_req\_method} %{referer\_url}%{referer\_url\_querystring}"  
}

e.g: this is perfect case  
t referer GET [http://localhost/v1/.misplaced\_objects,?format=json&marker=&end\_marker=](http://localhost/v1/.misplaced_objects,?format=json&marker=&end_marker=)  
t referer\_req\_method GET  
t referer\_url [http://localhost/v1/.misplaced\_objects](http://localhost/v1/.misplaced_objects), -  
t referer\_url\_querystring ?format=json&marker=&end\_marker=

But some time 1 field is null, thus after combine, null field will be %{referer\_url\_querystring}  
t referer HEAD [http://xxx.com/v1/AUTH\_xxx%{referer\_url\_querystring}](http://xxx.com/v1/AUTH_xxx%25%7Breferer_url_querystring%7D)  
t referer\_req\_method HEAD  
t referer\_url [http://xxx.com/v1/AUTH\_xxx](http://xxx.com/v1/AUTH_xxx)  
t referer\_url\_querystring -

Or all of them are null then i will get %{referer\_req\_method} %{referer\_url}%{referer\_url\_querystring}  
referer %{referer\_req\_method} %{referer\_url}%{referer\_url\_querystring}  
t referer\_req\_method -  
t referer\_url -  
t referer\_url\_querystring -

how can I ignore the field is null when i combine them ?

---

<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 19, 2017, 5:18pm UTC](https://discuss.elastic.co/t/how-to-ignore-fields-is-null-when-i-combine-them/83235/2 "2017-05-19T17:18:38Z")

</div>

Closed on May 19, 2017, 5:18pm UTC

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