How to create array data type from CSV

Hey, let's assume I have the following CSV and I would like to populate it into world_cup_2018 index

csv: groups.csv
Group A|Uruguay,Russia,Saudi Arabia,Egypt
Group B|Spain,Portugal,Iran,Morocco
....

I would like to create the following fields on my index:
group_name:string
teams: array

My logstash script:


input
{
file{
start_position => "beginning"
path => "/home/groups.csv"
"sincedb_path" => "/dev/null"
}
}

filter
{
csv {
separator => "|"
columns => [
'group_name',
'teams'
]
}
}

output
{
elasticsearch {
hosts => ["https://localhost:9243"]
index => ["world_cup_2018"]
manage_template => false
}
stdout { codec => "rubydebug" }
#stdout { codec => "dots" }
}


Is it possible? If yes, what should I change in this script in order to convert teams field into an array, with comma as my separator?

Thanks!

You can do that using a mutate+split operator.

1 Like

This is exactly what I was looking for, thanks :slight_smile:

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