Hello everyone,
I'm facing an issue regarding storing coordinates as geo_point. My goal is to add documents to ElasticSearch through a Logstash pipeline which I receive in JSON format. Omitting most of the fields the JSON looks like this:
{
"text": "hello",
"location": {
"lat": "42.5064128",
"lon": "1.52069438894224"
}
}
Since I'm new to the ELK stack I've created a minimal, complete and verifiable example:
/etc/logstash/conf.d/mycompany-tweet-demo.conf:
input {
tcp {
port => 10000
codec => "json"
}
}
filter {
mutate {
# this "works", however the location in no way matches the coordinates when displayed via tile map in Kibana
#add_field => { "mylocation" => 52 }
#add_field => { "mylocation" => 8 }
# this yields "illegal latitude value [268.76953125] for mylocation"
add_field => { "mylocation" => 51.9 }
add_field => { "mylocation" => 7.9 }
# this yields "illegal latitude value [269.1322946548462] for mylocation" for the demo JSON
#add_field => { "mylocation" => "%{[location][lat]}" }
#add_field => { "mylocation" => "%{[location][lon]}" }
}
}
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "mycompany-tweet-demo"
document_type => "tweet"
template => "/etc/logstash/templates/mycompany-demo-template.json"
template_overwrite => true
}
}
/etc/logstash/templates/mycompany-demo-template.json:
{
"template": "mycompany-*",
"mappings": {
"_default_": {
"properties": {
"mylocation" : {
"type" : "geo_point"
}
}
}
}
}
~/one.json:
{"text":"hello","location":{"lat":"42.5064128","lon":"1.52069438894224"}}
cat ~/one.json | nc localhost 10000
[2017-01-13T17:41:38,504][WARN ][logstash.outputs.elasticsearch] Failed action. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"mycompany-tweet-demo", :_type=>"tweet", :_routing=>nil}, 2017-01-13T16:41:38.458Z 0:0:0:0:0:0:0:1 %{message}], :response=>{"index"=>{"_index"=>"mycompany-tweet-demo", "_type"=>"tweet", "_id"=>"AVmYtLvEovM5deO5CNpA", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"illegal latitude value [269.1322946548462] for mylocation"}}}}}
Based on the documentation of geo_point and some posts on stackoverflow I've read, I'd expect my example with values between 0 and 90 to work. Could anyone point out what I'm doing wrong?