# Split an array of arrays

**URL:** <https://discuss.elastic.co/t/split-an-array-of-arrays/263724>\
**Category:** Logstash\
**Created:** [February 9, 2021, 11:56am UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724 "2021-02-09T11:56:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![opellulo](https://avatars.discourse-cdn.com/v4/letter/o/e19adc/32.png) [@opellulo](https://discuss.elastic.co/u/opellulo)\
**Post date:** [February 9, 2021, 11:56am UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724/1 "2021-02-09T11:56:33Z")

</div>

Hi all,  
I'm currently working on parsing a really nasty xml stream: events come in single file form, can get up to 5000 lines and, most important, includes arrays of arrays which crucially hold the data I need to parse and visualize.

After some tinkering I come to the solution of using multiple split filters: one for main array and others for the sub-arrays, this solution however leaves me in the cold if the subarray includes fields which i have not included (case I fear will come up sooner or later).

Is there any way to make the Split filter recursive so that it could manage any kind of subarrays?  
I understand this would be very load intensive, but given the scope of the project, this is something already expected.

Regards

---

<div class="post-metadata">

**Author:** ![kavierkoo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kavierkoo/32/86555_2.png) [@kavierkoo](https://discuss.elastic.co/u/kavierkoo)\
**Post date:** [February 9, 2021, 2:23pm UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724/2 "2021-02-09T14:23:59Z")

</div>

Hi Opellulo,

Have you took a look at XML Filter?

```
filter {
  xml {
    source => "message"
  }
}

```

> **[Xml filter plugin | Logstash Reference \[7.10\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-filters-xml.html)**

Hope this can help!!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 9, 2021, 4:24pm UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724/3 "2021-02-09T16:24:27Z")

</div>

> [@opellulo](#):
>
> Is there any way to make the Split filter recursive so that it could manage any kind of subarrays?

No, it will only split the field you tell it to split.

---

<div class="post-metadata">

**Author:** ![opellulo](https://avatars.discourse-cdn.com/v4/letter/o/e19adc/32.png) [@opellulo](https://discuss.elastic.co/u/opellulo)\
**Post date:** [February 11, 2021, 9:22am UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724/4 "2021-02-11T09:22:20Z")

</div>

Thanks for the replies,  
I suppose that the "correct" way to do that is through xpath (which to be honest i don't want to dive into unless someone can grant me beforehand it can handle nested arrays) so I think that for the moment I will stick to the multiple splits. It may not be elegant but it works.

---

<div class="post-metadata">

**Author:** ![opellulo](https://avatars.discourse-cdn.com/v4/letter/o/e19adc/32.png) [@opellulo](https://discuss.elastic.co/u/opellulo)\
**Post date:** [February 12, 2021, 10:52am UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724/5 "2021-02-12T10:52:00Z")

</div>

After some testing it seems I find the error: the XML has an array node and multiples attributes in that very node and its children, so with a default xml filter configuration, logstash was mixing the values giving me a lot of headache.

The situation improved a lot after having changed those xml filter parameters:

```
force_array => false
force_content => true

```

All while keeping the split for the array node  
Now I only got a cosmetic split error if the array node has only 1 value (it become an hash so it's not splittable) but i can live with it removing the tag

---

<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:** [March 12, 2021, 10:52am UTC](https://discuss.elastic.co/t/split-an-array-of-arrays/263724/6 "2021-03-12T10:52:59Z")

</div>

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