gofbor
(Gofbor)
May 7, 2019, 8:57am
1
Hi,
I've got index with geo_shape type field.
I can POST doc via dev_tool:
For example:
POST test/doc
{
"geo_link" : {
"type": "LineString",
"coordinates": [
[
-87.623177,
41.881832
],
[
-86.623177,
42.881832
]
]
}
}
But when I try to post records via logstash I've got error: "geo coordinates must be numbers".
Logstash file:
input {...}
filter {
mutate {
add_field => [ "[geo_link][type]", "linestring" ]
add_field => [ "[geo_link][coordinates]",[[ -87.623177, 41.881832], [ -86.623177, 42.881832]] ]
}
}
output {...}
I tried many combinations of coordination number but I always have the same error.
I have the same problem , how to do indexing correctly a linestring via logstash?
gofbor:
add_field => [ "[geo_link][coordinates]",[[ -87.623177, 41.881832], [ -86.623177, 42.881832]] ]
That results in
"geo_link" => {
"type" => "linestring",
"coordinates" => [
[0] "[-87.623177, 41.881832]",
[1] "[-86.623177, 42.881832]"
]
},
for me. You can split it up
add_field => {
"[geo_link][type]" => "linestring"
"[geo_link][coordinates][0]" => [ -87.623177, 41.881832]
"[geo_link][coordinates][1]" => [ -87.623177, 41.881833]
}
}
which results in
"geo_link" => {
"type" => "linestring",
"coordinates" => {
"1" => [
[0] "-87.623177",
[1] "41.881833"
],
"0" => [
[0] "-87.623177",
[1] "41.881832"
]
}
},
Note that these coordinates are all strings, not numbers. You may need to mutate+convert them.
gofbor
(Gofbor)
May 8, 2019, 9:10am
4
Thanks for reply.
But now I have message: "coordinates cannot be specified as objects"
I tried:
{
add_field => [ "[geo_link][type]", "linestring" ]
add_field => [ "[geo_link][coordinates][0]", "[ -87.623177, 41.881832 ]" ]
add_field => [ "[geo_link][coordinates][1]", "[ -87.623177, 41.881832 ]" ]
convert => { "[geo_link][coordinates][0]" => "float" }
convert => { "[geo_link][coordinates][1]" => "float" }
}
I also tried:
add_field => [ "[geo_link][type]", "linestring" ]
add_field => [ "[geo_link][coordinates][0][lat]", " -87.623177" ]
add_field => [ "[geo_link][coordinates][0][lon]", "41.881832" ]
add_field => [ "[geo_link][coordinates][1][lat]", " -87.623177" ]
add_field => [ "[geo_link][coordinates][1][lon]", "41.881832" ]
but the same result.
I also tried:
add_field => [ "[geo_link][type]", "linestring" ]
add_field => [ "[geo_link][coordinates][0][0]", " -87.623177" ]
add_field => [ "[geo_link][coordinates][0][1]", "41.881832" ]
add_field => [ "[geo_link][coordinates][1][0]", " -87.623177" ]
add_field => [ "[geo_link][coordinates][1][1]", "41.881832" ]
but the same result.
I cannot see a way to create an array of arrays of floats using mutate. So use ruby
mutate {
add_field => {
"[geo_link][type]" => "linestring"
}
}
ruby {
code => '
event.set("[geo_link][coordinates]", [[ -87.623171, 41.881832], [ -87.623177, 41.881833]])
'
}
which results in
"geo_link" => {
"type" => "linestring",
"coordinates" => [
[0] [
[0] -87.623171,
[1] 41.881832
],
[1] [
[0] -87.623177,
[1] 41.881833
]
]
},
1 Like
parosio
(Parosio)
May 8, 2019, 2:06pm
7
Thank you for sharing this workaround!
Works perfectly !!
Many thanks
system
(system)
Closed
June 5, 2019, 2:35pm
10
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.