# Dissect and kv filter

**URL:** https://discuss.elastic.co/t/dissect-and-kv-filter/165250
**Category:** Logstash
**Created:** [January 22, 2019, 2:08pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250 "2019-01-22T14:08:59Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Necus](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@Necus](https://discuss.elastic.co/u/Necus)
#### Post date: [January 22, 2019, 2:08pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/1 "2019-01-22T14:08:59Z")

</div>

Hi,  
I'm using dissect filter to quickly parse data. Then i would like to use kv to divide one of the newly created field into many values.

new field:  
field1=value1,field2=value2,field3=[abc, abc2, abc3],field4=value4

dissect  
field1=%{field1},field2=%{field2},field3=%{field3},field4=%{field4}

Dissect works fine (i'm filtering out "[" and "]", but how can I create appriopriate kv filter?

This does not appear to work:  
kv {  
source =\> "field3"  
field\_split =\> ", "  
}

---

<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: [January 22, 2019, 2:27pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/2 "2019-01-22T14:27:47Z")

</div>

field3 appears to be csv, not kv.

---

<div class="post-metadata">

### Author: ![Necus](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@Necus](https://discuss.elastic.co/u/Necus)
#### Post date: [January 22, 2019, 2:40pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/3 "2019-01-22T14:40:27Z")

</div>

Ok,  
Still something is wrong

if:  
csv {  
source =\> "field3"  
separator =\> ", "  
}  
Error parsing csv {:field=\>"field3", :source=\>"", :exception=\>#\<NoMethodError: undefined method `each\_index' for nil:NilClass\>}

Update:  
After changing ", " to "," it works (9 out of 10 times, rest error :exception=\>#\<NoMethodError: undefined method `each\_index' for nil:NilClass), but instead of putting multiple value into role field it creates new fields "columns". Target =\> "role" does not work.

---

<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: [January 22, 2019, 3:12pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/4 "2019-01-22T15:12:57Z")

</div>

Not sure what to say. With

```
dissect { mapping => { "message" => "field1=%{field1},field2=%{field2},field3=[%{field3}],field4=%{field4}" } }
csv { source => "field3" separator => ", " target => "role" }

```

I get

```
      "role" => {
    "column2" => "abc2",
    "column1" => "abc",
    "column3" => "abc3"
},
```

---

<div class="post-metadata">

### Author: ![Necus](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@Necus](https://discuss.elastic.co/u/Necus)
#### Post date: [January 22, 2019, 3:21pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/5 "2019-01-22T15:21:29Z")

</div>

And how to change to this:  
csv {  
source =\> "field3"  
separator =\> ", "  
target =\> "field3"  
}  
I do not want any new columns fields, I only want one "field3" multivalue field

---

<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: [January 22, 2019, 3:24pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/6 "2019-01-22T15:24:15Z")

</div>

If you want field3 to be an array get rid of the csv filter and use

```
mutate { split => { "field3" => ", " } }

```

which gets you

```
    "field3" => [
    [0] "abc",
    [1] "abc2",
    [2] "abc3"
],
```

---

<div class="post-metadata">

### Author: ![Necus](https://avatars.discourse-cdn.com/v4/letter/n/e47774/32.png) [@Necus](https://discuss.elastic.co/u/Necus)
#### Post date: [January 28, 2019, 8:19pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/7 "2019-01-28T20:19:35Z")

</div>

Thank you 🙂

---

<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: [February 25, 2019, 8:19pm UTC](https://discuss.elastic.co/t/dissect-and-kv-filter/165250/8 "2019-02-25T20:19:36Z")

</div>

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