# Dissecting an array of variable length

**URL:** <https://discuss.elastic.co/t/dissecting-an-array-of-variable-length/169681>\
**Category:** Logstash\
**Created:** [February 23, 2019, 7:56pm UTC](https://discuss.elastic.co/t/dissecting-an-array-of-variable-length/169681 "2019-02-23T19:56:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael.Swiss](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Michael.Swiss](https://discuss.elastic.co/u/Michael.Swiss)\
**Post date:** [February 23, 2019, 7:56pm UTC](https://discuss.elastic.co/t/dissecting-an-array-of-variable-length/169681/1 "2019-02-23T19:56:18Z")

</div>

Hi there

I am trying to dissect an array of variable length. That means it can contain up to 5 entries.  
Using the dissect plugin however requires me to indicate a fixed length and results in an [0] "\_dissectfailure" return.  
Is there any way to do this?

Best Michael

Examples:

The array:  
"POI\_array2\_translated2" =\> [  
[0] "Gandeggh?tte (3'030 m)$Bergh?tte mit Restaurant, Aussichtsterrasse und ?bernachtungsm?glichkeit (?ffnungszeiten beachten)$POIS49.jpg",  
[1] "Trockener Steg (2'929 m)$Bergstation mit Shop, Restaurant und Aussichtsterrasse$POIS153.jpg"  
]

The dissect plugin:  
dissect {  
mapping =\> {  
"POI\_array2\_translated2" =\> "%{POI1\_translated}, %{POI2\_translated}, %{POI3\_translated}, %{POI4\_translated}, %{POI5\_translated}"  
}  
}

---

<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 23, 2019, 8:02pm UTC](https://discuss.elastic.co/t/dissecting-an-array-of-variable-length/169681/2 "2019-02-23T20:02:59Z")

</div>

dissect will not work. You can do it in ruby

```
    ruby {
        code => '
            a = event.get("POI_array2_translated2")

            if a then
                a.each_index { |i|
                    event.set("POI#{i+1}_translated", a[i])
                }
            end
        '
    }
```

---

<div class="post-metadata">

**Author:** ![Michael.Swiss](https://avatars.discourse-cdn.com/v4/letter/m/c5a1d2/32.png) [@Michael.Swiss](https://discuss.elastic.co/u/Michael.Swiss)\
**Post date:** [February 24, 2019, 10:54am UTC](https://discuss.elastic.co/t/dissecting-an-array-of-variable-length/169681/3 "2019-02-24T10:54:30Z")

</div>

Dear Badger  
This works. Thanks a lot  
Michael

---

<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 24, 2019, 10:54am UTC](https://discuss.elastic.co/t/dissecting-an-array-of-variable-length/169681/4 "2019-03-24T10:54:36Z")

</div>

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