# How to write rows of a Streaming DataFrame to multiple ElasticSearch indices?

**URL:** <https://discuss.elastic.co/t/how-to-write-rows-of-a-streaming-dataframe-to-multiple-elasticsearch-indices/131711>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [May 14, 2018, 10:01am UTC](https://discuss.elastic.co/t/how-to-write-rows-of-a-streaming-dataframe-to-multiple-elasticsearch-indices/131711 "2018-05-14T10:01:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kant\_kodali](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kant_kodali/32/50637_2.png) [@kant\_kodali](https://discuss.elastic.co/u/kant_kodali)\
**Post date:** [May 14, 2018, 10:01am UTC](https://discuss.elastic.co/t/how-to-write-rows-of-a-streaming-dataframe-to-multiple-elasticsearch-indices/131711/1 "2018-05-14T10:01:55Z")

</div>

How to write rows of a Streaming DataFrame to multiple ElasticSearch indices? For example I want to write row1 of a dataframe to index1, row2 of a dataframe to index2 , row3 of a dataframe to index3 and so on ...I have about 15 different indices so it would a bit painful and not a very clean code If were to filter and call writeStream() 15 times. so I am wondering if there is any easier way like the kafka dataframe below?

If I take Kafka data frame example it has the following schema by default.

```
root
 |-- key: binary (nullable = true)
 |-- value: binary (nullable = true)
 |-- topic: string (nullable = true)
 |-- partition: integer (nullable = true)
 |-- offset: long (nullable = true)
 |-- timestamp: timestamp (nullable = true)
 |-- timestampType: integer (nullable = true)

```

so I can have a topic field for every row such that the kafka connector takes care of write rows to appropriate topics.

---

<div class="post-metadata">

**Author:** ![james.baiera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/james.baiera/32/10209_2.png) [@james.baiera](https://discuss.elastic.co/u/james.baiera)\
**Post date:** [May 16, 2018, 6:39pm UTC](https://discuss.elastic.co/t/how-to-write-rows-of-a-streaming-dataframe-to-multiple-elasticsearch-indices/131711/2 "2018-05-16T18:39:48Z")

</div>

You could try using the multi-resource index writing feature described in [the docs](https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html#cfg-multi-writes-format)

---

<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:** [June 13, 2018, 6:39pm UTC](https://discuss.elastic.co/t/how-to-write-rows-of-a-streaming-dataframe-to-multiple-elasticsearch-indices/131711/3 "2018-06-13T18:39:50Z")

</div>

Closed on June 13, 2018, 6:39pm UTC

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