# How to remove configuration option from document \[SOLVED\]

**URL:** <https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832>\
**Category:** Logstash\
**Created:** [November 3, 2016, 9:55am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832 "2016-11-03T09:55:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Archer](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@Archer](https://discuss.elastic.co/u/Archer)\
**Post date:** [November 3, 2016, 9:55am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/1 "2016-11-03T09:55:06Z")

</div>

**## when i config like this**

input {  
redis {  
host =\> "127.0.0.1"  
port =\> 6379  
key =\> "logstash:test"  
data\_type =\> "list"  
codec =\> "json"  
type =\> "%{[type]}"  
}  
}

output {  
elasticsearch {  
hosts =\> ["127.0.0.1:9200"]  
document\_id =\> "%{[id]}"  
action =\> "%{[action]}"  
index =\> "%{[index]}"  
}  
}

\*\*

## and i set key in redis like this :

\*\*

lpush logstash:test '{"id" :"2","action": "index","name":"test","index":"blog","type":"1"}'

\*\*

## in elasticsearch

\*\*

{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "blog",  
"\_type": "1",  
"\_id": "2",  
"\_score": 1,  
"\_source": {  
"@timestamp": "2016-11-03T08:54:43.994Z",  
"name": "test",  
"@version": "1",  
"action": "index",  
"index": "blog",  
"id": "2",  
"type": "1"  
}  
}  
]  
}  
}

**but i don't want action ,index ,id ,and type in the field,i only want these as follows**

{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "blog",  
"\_type": "1",  
"\_id": "2",  
"\_score": 1,  
"\_source": {  
"@timestamp": "2016-11-03T08:54:43.994Z",  
"name": "test",  
"@version": "1"  
}  
}  
]  
}  
}

how can i do? thanks

Regards,  
Archer

---

<div class="post-metadata">

**Author:** ![jsvd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsvd/32/6203_2.png) [@jsvd](https://discuss.elastic.co/u/jsvd)\
**Post date:** [November 3, 2016, 10:27am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/2 "2016-11-03T10:27:49Z")

</div>

you can move these fields to the `@metadata` field, they aren't pushed to elasticsearch:

```auto
filter {
  mutate {
    rename => {
      "action" => "[@metadata][action]"
      "index" => "[@metadata][index]"
      "id" => "[@metadata][id]"
      "type" => "[@metadata][type]"
    }
  }
}
output {
  elasticsearch {
    hosts => ["127.0.0.1:9200"]
    document_id => "%{[@metadata][id]}"
    action => "%{[@metadata][action]}"
    index => "%{[@metadata][index]}"
  }
}

```

---

<div class="post-metadata">

**Author:** ![Archer](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@Archer](https://discuss.elastic.co/u/Archer)\
**Post date:** [November 4, 2016, 5:43am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/3 "2016-11-04T05:43:24Z")

</div>

**Hi,jsvd, thanks for you help.but it seems that the field 'type' always be 'log'**  
as follows:  
"\_index": "blog",  
"\_type": "logs",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"@timestamp": "2016-11-04T05:27:17.364Z",  
"name": "test21",  
"@version": "1",  
"content": "update"

**the configuration**

```
input {
  redis {
    host => "127.0.0.1"
    port => 6379
    key => "logstash:test"
    data_type => "list"
    codec => "json"
    type => "%{[type]}"
  }
}

filter {
  mutate {
    rename => {
      "action" => "[@metadata][action]"
      "index" => "[@metadata][index]"
      "id" => "[@metadata][id]"
      "type" => "[@metadata][type]"
    }
  }
}

output {
  elasticsearch {
    hosts => ["127.0.0.1:9200"]
    document_id => "%{[@metadata][id]}"
    action => "%{[@metadata][action]}"
    index => "%{[@metadata][index]}"
  }
}

```

btw,i use type =\> %{[@metadata][type]} instead of %{[type]},still can not work  
**_so how can i accept the "type" ?_**

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 4, 2016, 5:51am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/4 "2016-11-04T05:51:22Z")

</div>

Using `type => "%{[type]}"` in an input doesn't make sense. What do you want the document type to be? Same for all events arriving via your redis input? Or set based on the JSON payload? In the latter case I suspect you can just drop the `type` option for your input.

---

<div class="post-metadata">

**Author:** ![Archer](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@Archer](https://discuss.elastic.co/u/Archer)\
**Post date:** [November 4, 2016, 6:02am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/5 "2016-11-04T06:02:53Z")

</div>

hi,magnusbaeck,thanks for you help.

i want the document type to be what i set in the redis.

for example:  
the JSON set in redis

## '{"id" :"1","action": "index","name":"test21","index":"blog","type":"type-test","content":"update"}'

what I expect in document is

"\_index": "blog",  
"\_type": " **type-test**",  
"\_id": "1",  
"\_score": 1,  
"\_source": {  
"@timestamp": "2016-11-04T05:55:34.382Z",  
"name": "test21",  
"@version": "1",  
"content": "update"

but now the "type" always be "logs".

and it seems that i drop the type option for my input does not work:confused:

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 4, 2016, 6:10am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/6 "2016-11-04T06:10:38Z")

</div>

Please show your current configuration and what a sample event looks like. Use a `stdout { codec => rubydebug }` so we can see exactly what the event looks like.

---

<div class="post-metadata">

**Author:** ![Archer](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@Archer](https://discuss.elastic.co/u/Archer)\
**Post date:** [November 4, 2016, 7:44am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/7 "2016-11-04T07:44:24Z")

</div>

thanks, I use "document\_type" in output instead of "type" in input,and it works.  
But thanks a lot !

---

<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:** [July 6, 2017, 4:31am UTC](https://discuss.elastic.co/t/how-to-remove-configuration-option-from-document-solved/64832/8 "2017-07-06T04:31:09Z")

</div>

Closed on July 6, 2017, 4:31am UTC


