# Elasticsearch index not getting created when add\_field is used

**URL:** <https://discuss.elastic.co/t/elasticsearch-index-not-getting-created-when-add-field-is-used/243825>\
**Category:** Logstash\
**Created:** [August 5, 2020, 8:31am UTC](https://discuss.elastic.co/t/elasticsearch-index-not-getting-created-when-add-field-is-used/243825 "2020-08-05T08:31:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![christiancj](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@christiancj](https://discuss.elastic.co/u/christiancj)\
**Post date:** [August 5, 2020, 12:17pm UTC](https://discuss.elastic.co/t/elasticsearch-index-not-getting-created-when-add-field-is-used/243825/2 "2020-08-05T12:17:11Z")

</div>

looks to me the error is around the else if conditions and the way to set the add field, instead you should use nested else conditions, try this below,

```auto
if "data_one" in [data] {
    		mutate {
				add_field => { "Desc" => ["Snap"] }
    		}
    	} # end if "data_one"
    	else {
			if "data_two" in [data] {
				mutate {
					add_field => { "Desc" => ["Snaptwo"] }
				}
			} # end if "data_two"
			else {
				if "data_three" in [data] {
					mutate {
						add_field => { "Description" => ["Snapthree"] }
					}
				} # end if "data_three"		
			} # end 2nd else
		} # end 1st else

```

also, another similar post

> [@Multiple IF conditions - Logstash](https://discuss.elastic.co/t/multiple-if-conditions-logstash/166186):
>
> Hi, I am fixing bigger logstash config file where I have custom grok patterns but that is just tip of the iceberg regarding my problems. In Filebeat I have multiple log files and some of them (their log events) are visible in Kibana ok, and some not because their content ends up in the message field. Some log events are not even visible in Kibana when I try to filter it by tags in Kibana. I can fix stuff if I have one IF statement but when multiple IF statements are involved I am not sure wha…

---

_[View the full topic](https://discuss.elastic.co/t/elasticsearch-index-not-getting-created-when-add-field-is-used/243825)._
