# Logstash kafka topic as part of elasticsearch document\_type

**URL:** <https://discuss.elastic.co/t/logstash-kafka-topic-as-part-of-elasticsearch-document-type/97044>\
**Category:** Logstash\
**Created:** [August 15, 2017, 1:50am UTC](https://discuss.elastic.co/t/logstash-kafka-topic-as-part-of-elasticsearch-document-type/97044 "2017-08-15T01:50:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sulthonzh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sulthonzh/32/21035_2.png) [@sulthonzh](https://discuss.elastic.co/u/sulthonzh)\
**Post date:** [August 15, 2017, 1:50am UTC](https://discuss.elastic.co/t/logstash-kafka-topic-as-part-of-elasticsearch-document-type/97044/1 "2017-08-15T01:50:05Z")

</div>

I have tried this conf but not working

```
  input {
      kafka {    
        ...
        decorate_events => true
      }
    }

    filter {    
      mutate {
        add_field => {"[@metadata][topic]" => "%{[kafka][topic]}"}
      }
    }

    output {
      elasticsearch {
        document_type => "%{[@metadata][topic]}"
        ...
      }
    }

```

result of "%{[@metadata][topic]}"

> "%{[kafka][topic]}"

---

<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:** [September 12, 2017, 1:50am UTC](https://discuss.elastic.co/t/logstash-kafka-topic-as-part-of-elasticsearch-document-type/97044/2 "2017-09-12T01:50:25Z")

</div>

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