Arrays in arrays


(B) #1

Hi everyone,

I am trying to index geoshapes from kafka messages ...

I just can not use the merge to put arrays in an array.

For instance, i want to index an envelope geoshape like this in target elasticsearch json:

[...]
"location" : {
"type":"envelope",
"coordinates": [ [x1,y1], [x2,y2] ]
},
[...]

I tryed this:

mutate {
    convert => {
       "x1" => float
       "x2" => float
       "y1" => float
       "y2" => float
    }
    merge => { "x1" => "y1"}
    merge => { "x2" => "y2" }
    merge => { "coordinates" => "x1" }
    merge => { "coordinates" => "x2" }

But as a result I found:

"coordinates": [x2,y2]

and not

"coordinates":[[x1,y1],[x2,y2]

Any idea on how to achieve this ?
I thought about the ruby code filter but I definitely do not master the syntax :frowning:

Thanks for your help !


(B) #2

I have finally found a solution to add my geohash.

mutate {
convert => {
"x1" => float
"x2" => float
"y1" => float
"y2" => float
}
merge => { "x1" => "y1"}
merge => { "x2" => "y2" }
}
ruby {
code => 'event.set("[location][type]","envelope");event.set("[location][coordinates]",[event.get("x1"),event.get("x2")])'
remove_field => [ "x1", "x2", "y1", "y2" ]
}


(system) #3

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