# Index only specific data in elasticsearch from kafka input

**URL:** <https://discuss.elastic.co/t/index-only-specific-data-in-elasticsearch-from-kafka-input/65970>\
**Category:** Logstash\
**Created:** [November 14, 2016, 12:11pm UTC](https://discuss.elastic.co/t/index-only-specific-data-in-elasticsearch-from-kafka-input/65970 "2016-11-14T12:11:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![scireon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scireon/32/13149_2.png) [@scireon](https://discuss.elastic.co/u/scireon)\
**Post date:** [November 14, 2016, 12:11pm UTC](https://discuss.elastic.co/t/index-only-specific-data-in-elasticsearch-from-kafka-input/65970/1 "2016-11-14T12:11:20Z")

</div>

I am using kafka as my input and put it in elasticsearch (output)

```
input {
    kafka {
        topics => ["maxwell"]
        codec => json
    }
}
filter {
}
output {
    stdout { codec => rubydebug }
    elasticsearch {
        index => 'test_kafka'
        document_type => "%{table}"
        hosts => 'localhost:9200'
    }
}
```

When this runs, it outputs the following json

```
{
  "database": "my_db",
  "xid": 88935,
  "@timestamp": "2016-11-14T12:00:13.763Z",
  "data": {
    "contact_country_code": null,
    "contact_type_id": 1,
    "created": "2014-10-03 12:24:36",
    "modified_by": null,
    "modified": "2014-10-03 12:24:36",
    "contact_id": 1,
    "is_default": 0,
    "created_by": null,
    "contact_number": "1241222232"
  },
  "old": {
    "contact_number": "1241222"
  },
  "commit": true,
  "@version": "1",
  "type": "update",
  "table": "contact",
  "ts": 1479124813
}
```

My question is, how can I only extract the `data` key with dynamic `document_type` in elasticsearch to achieve the this one

```
{
  "_index": "test_kafka",
  "_type": "contact",
  "_id": "AVhitY804rvpX8qdVt9d",
  "_score": 1,
  "_source": {
    "contact_country_code": null,
    "contact_type_id": 1,
    "created": "2014-10-03 12:24:36",
    "modified_by": null,
    "modified": "2014-10-03 12:24:36",
    "contact_id": 1,
    "is_default": 0,
    "created_by": null,
    "contact_number": "1241222232"
  }
}
```

---

<div class="post-metadata">

**Author:** ![scireon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scireon/32/13149_2.png) [@scireon](https://discuss.elastic.co/u/scireon)\
**Post date:** [November 16, 2016, 5:14am UTC](https://discuss.elastic.co/t/index-only-specific-data-in-elasticsearch-from-kafka-input/65970/2 "2016-11-16T05:14:03Z")

</div>

Topic can be followed here. [http://stackoverflow.com/questions/40600708/logstash-index-only-specific-data-in-elasticsearch-from-kafka-input/40602386#40602386](http://stackoverflow.com/questions/40600708/logstash-index-only-specific-data-in-elasticsearch-from-kafka-input/40602386#40602386)

---

<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:** [December 14, 2016, 5:14am UTC](https://discuss.elastic.co/t/index-only-specific-data-in-elasticsearch-from-kafka-input/65970/3 "2016-12-14T05:14:04Z")

</div>

Closed on December 14, 2016, 5:14am UTC

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