# Seperate the elements into multiple documents using ingest pipeline

**URL:** <https://discuss.elastic.co/t/seperate-the-elements-into-multiple-documents-using-ingest-pipeline/376752>\
**Category:** Elasticsearch\
**Tags:** ingest-pipeline\
**Created:** [April 3, 2025, 3:39pm UTC](https://discuss.elastic.co/t/seperate-the-elements-into-multiple-documents-using-ingest-pipeline/376752 "2025-04-03T15:39:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai7276p](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sai7276p/32/117764_2.png) [@sai7276p](https://discuss.elastic.co/u/sai7276p)\
**Post date:** [April 3, 2025, 3:39pm UTC](https://discuss.elastic.co/t/seperate-the-elements-into-multiple-documents-using-ingest-pipeline/376752/1 "2025-04-03T15:39:31Z")

</div>

Hi

I want to create multiple documents/events based on the target field. Target field contains multiple elements and want to seperate it and create multiple documents using ingest pipeline. I tried with foreach and script processor but it is not working. We can't use logstash here as there are some restrictions.

Data looks like this,

> {"ErrorCode":"E00065427","errorSummary":"Sorry, there's been an error.","errorId":"hshehje-yehhbs","target":[{"id":"5266262727","type":"A","display\_name","X","alternate\_id":"unknown"},{"id":"526727278327","type":"B","display\_name":"Y","alternate\_id":"unknown"},{"id":"6636377373","type":"C","display\_name":"Z","alternate\_id":"unknown"}]}

---

<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 3, 2025, 4:30pm UTC](https://discuss.elastic.co/t/seperate-the-elements-into-multiple-documents-using-ingest-pipeline/376752/2 "2025-04-03T16:30:01Z")

</div>

Ingest pipelines can not split a document into multiple ones, only Logstash can.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [April 3, 2025, 4:58pm UTC](https://discuss.elastic.co/t/seperate-the-elements-into-multiple-documents-using-ingest-pipeline/376752/3 "2025-04-03T16:58:04Z")

</div>

How are you indexing the data?

This is something that is not possible to do with Ingest Pipelines.

It can be easily done with Logstash using the `split` filter and some inputs of Elastic Agent can also do the same split, basically the Kafka input and the httpjson have ways to split data into multiple events before sending the data to Elasticsearch.

---

<div class="post-metadata">

**Author:** ![Keith\_Massey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keith_massey/32/83666_2.png) [@Keith\_Massey](https://discuss.elastic.co/u/Keith_Massey)\
**Post date:** [April 3, 2025, 8:00pm UTC](https://discuss.elastic.co/t/seperate-the-elements-into-multiple-documents-using-ingest-pipeline/376752/4 "2025-04-03T20:00:32Z")

</div>

This is a frequently-requested processor that is unfortunately much more difficult to implement than you would think. Here is a summary: [[Ingest Pipeline] Ability to split documents · Issue #56769 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/56769#issuecomment-2034715571)
