# Jdbc add field

**URL:** <https://discuss.elastic.co/t/jdbc-add-field/76899>\
**Category:** Logstash\
**Created:** [March 1, 2017, 2:00am UTC](https://discuss.elastic.co/t/jdbc-add-field/76899 "2017-03-01T02:00:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greentea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greentea/32/15924_2.png) [@Greentea](https://discuss.elastic.co/u/Greentea)\
**Post date:** [March 1, 2017, 2:00am UTC](https://discuss.elastic.co/t/jdbc-add-field/76899/1 "2017-03-01T02:00:58Z")

</div>

Hi!  
I am trying to add field in to a type by using if statement. But logstash report error

```
[LogStash::Runner] ERROR logstash.agent - fetched an invalid config

```

Here is my filter part

```
filter {
if [type]=product{
mutate {
	add_field => { "product_suggest" => "%{display_name}" }
	add_field => { "product_suggester" => "%{display_name}" }
	remove_field => ["attribute_value_en ", "attribute_value_sc "]
}
}
if [type]=merchant{
mutate {
	add_field => { "merchant_suggest" => "%{merchant_name}" }
	add_field => { "merchant_suggester" => "%{merchant_name}" }
}
}
}

```

Does any one get some idea where I worry? or any method that can add field by type?

---

<div class="post-metadata">

**Author:** ![Greentea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/greentea/32/15924_2.png) [@Greentea](https://discuss.elastic.co/u/Greentea)\
**Post date:** [March 1, 2017, 2:52am UTC](https://discuss.elastic.co/t/jdbc-add-field/76899/2 "2017-03-01T02:52:19Z")

</div>

I found the problem, it should write like this

```
filter {
if [type] == "product"{
	mutate {
		add_field => { "product_suggest" => "%{display_name}" }
		add_field => { "product_suggester" => "%{display_name}" }
		remove_field => ["attribute_value_en", "attribute_value_sc"]
	}
}
if [type] == "merchant"{
	mutate {
		add_field => { "merchant_suggest" => "%{merchant_name}" }
		add_field => { "merchant_suggester" => "%{merchant_name}" }
	}
}
}
```

---

<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:** [March 29, 2017, 2:52am UTC](https://discuss.elastic.co/t/jdbc-add-field/76899/3 "2017-03-29T02:52:33Z")

</div>

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