Hi, I'm trying to set geo_point type from csv files which have latitude and longitude using logstash. But I really don't know how to convert latitude and longitude to location(geo_point type). I'm using logstash for this, but it seems that there is not enough information about it.
I found this way.
input {
file {
path => "/Users/kakao/Downloads/coronavirusdataset_20200601/Case.csv"
start_position => "beginning"
#sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ","
columns => ["case_id","province","city","group","infection_case","confirmed","latitude","longitude"]
}
mutate {convert => ["latitude", "float"]}
mutate {convert => ["longitude", "float"]}
mutate {convert => ["confirmed", "float"]}
mutate {rename => ["latitude", "[location][lat]"]}
mutate {rename => ["longitude", "[location][lon]"]}
output {
elasticsearch {
template => "/Users/kakao/Downloads/logstash-7.7.1/config/elasticsearch-template.json"
template_overwrite => true
action => "index"
hosts => ["http://localhost:9200"]
index => "logstash-%{+YYYY.MM.dd}"
user => "user-name"
password => "password"
workers => 1
}
stdout {}
}
and this is my elasticsearch-template.json.
{
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true, "omit_norms" : true},
"dynamic_templates" : [ {
"message_field" : {
"match" : "message",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "analyzed", "omit_norms" : true,
"fielddata" : { "format" : "disabled" }
}
}
}, {
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "analyzed", "omit_norms" : true,
"fielddata" : { "format" : "disabled" },
"fields" : {
"raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
}
}
}
} ],
"properties" : {
"@timestamp": { "type": "date" },
"@version": { "type": "string", "index": "not_analyzed" },
"geoip" : {
"dynamic": true,
"properties" : {
"ip": { "type": "ip" },
"location" : { "type" : "geo_point" },
"latitude" : { "type" : "float" },
"longitude" : { "type" : "float" }
}
},
"location" : { "type": "geo_point" }
}
}
}
}
Finally, I got geoip.location which is geo_point type, but I couldn't find any data of geoip.location in discover. I only have location.lat, location.lon which are numbers. It means that I just have field, but no data in that field.