# Ingest Pipeline for routing data into 2 different indexes

**URL:** <https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189>\
**Category:** Elasticsearch\
**Created:** [April 15, 2020, 6:44pm UTC](https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189 "2020-04-15T18:44:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mack\_rogers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mack_rogers/32/53224_2.png) [@Mack\_rogers](https://discuss.elastic.co/u/Mack_rogers)\
**Post date:** [April 15, 2020, 6:44pm UTC](https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189/1 "2020-04-15T18:44:32Z")

</div>

How can you write into 2 different indexes using a ingest pipeline?

Example. a single doc with fields a , b, c, and d ?

index A will receive fields A & B

index B will receive fields C & D

How can I accomplish this with ingest pipelines?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [April 15, 2020, 6:51pm UTC](https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189/2 "2020-04-15T18:51:29Z")

</div>

You can not as far as I know. You need to do that split before you send the documents to Elasticsearch.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 17, 2020, 8:04am UTC](https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189/3 "2020-04-17T08:04:19Z")

</div>

Seconding what @Christian_Dahlqvist said. An ingest pipeline can write to only one index. So you can't split a document in two documents within an ingest pipeline.

---

<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:** [May 15, 2020, 8:04am UTC](https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189/4 "2020-05-15T08:04:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jennie\_Soria](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jennie_soria/32/58895_2.png) [@Jennie\_Soria](https://discuss.elastic.co/u/Jennie_Soria)\
**Post date:** [June 11, 2021, 7:13pm UTC](https://discuss.elastic.co/t/ingest-pipeline-for-routing-data-into-2-different-indexes/228189/5 "2021-06-11T19:13:38Z")

</div>

There maybe some options, with logstash for example

Ingest with logstash use the clone plugin to duplicate the document, tag (A,B: the original A and clone B), then use logic to send those tagged A to pipeline A, those tagged B to pipeline B. Then use the prune plugin to remove unwanted fields.

There is an example of this in this blog post: [Using Logstash to Split Data and Send it to Multiple Outputs | Elastic Blog](https://www.elastic.co/blog/using-logstash-to-split-data-and-send-it-to-multiple-outputs).

As for ingest you could likely do a pipeline to pipeline  
Alternatively, use logstash with 'pipeline to pipeline' [Pipeline-to-Pipeline Communication | Logstash Reference [7.13] | Elastic](https://www.elastic.co/guide/en/logstash/current/pipeline-to-pipeline.html)

For an ingest pipeline, use reindex from the source index to another index (need \_source enabled on docs to use reindex) [Ingest pipelines | Elasticsearch Guide [7.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html#add-pipeline-to-indexing-request)
