I found a solution myself with a lot of help from this post by Badger and thought I share it if others encounter the same issue.
First, the coordinates should not be arranged in an array in the inout.csv file. Of course you can split the array etc in logstash. But for convenience I arranged my coordinates as below:
-74.0446, 40.6899,-74.0416, 40.6996
My logstash.conf for converting the coordinates into a geo_point location and a linestring geo_shape. I have excluded the part not relevant for the geo operations.
filter {
csv { separator => ","
columns => [ "loc_lat","loc_lon","proj_lat","proj_lon" ]
}
mutate { add_field => ["[location]", "%{loc_lon}"]
add_field => ["[location]", "%{loc_lat}"]
}
mutate { convert => ["[location]", "float"]
convert => ["[loc_lat]", "float"]
convert => ["[loc_lon]", "float"]
convert => ["[proj_lat]", "float"]
convert => ["[proj_lon]", "float"]
}
mutate { add_field => ["[projection][type]", "linestring"]
}
ruby { code => "event.set('[projection][coordinates]', [[ event.get('loc_lon'), event.get('loc_lat')], [ event.get('proj_lon'), event.get('proj_lat')]])"
}
Result in cmd with rubedebug:
{
"projection" => {
"coordinates" => [
[0] [
[0] -74.0446,
[1] 40.6899
],
[1] [
[0] -74.0416,
[1] 40.6996
]
],
"type" => "linestring"
},
"location" => [
[0] -74.0446,
[1] 40.6899
]
}