elasticsearch 如何在elasticsearch、kibana、logstash中设置地理点类型?
我正在尝试使用logstash从具有纬度和经度的csv文件中设置geo_点类型。但我真的不知道如何将纬度和经度转换为位置(地理点类型)。我正在使用logstash,但似乎没有足够的信息。 我是这样发现的elasticsearch 如何在elasticsearch、kibana、logstash中设置地理点类型?,elasticsearch,mapping,logstash,kibana,elasticsearch,Mapping,Logstash,Kibana,我正在尝试使用logstash从具有纬度和经度的csv文件中设置geo_点类型。但我真的不知道如何将纬度和经度转换为位置(地理点类型)。我正在使用logstash,但似乎没有足够的信息。 我是这样发现的 input { file { path => "/Users/"name"/Downloads/coronavirusdataset_20200601/Case.csv" start_position => "beginning" #sincedb_pat
input {
file {
path => "/Users/"name"/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/"name"/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 {}
}
这是我的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" }
}
}
}
}
我一直在努力找出问题所在,并且找到了使用kibana开发工具的方法。我还更改了我的logstash conf文件,没有使用上面使用的elasticsearch-template.json。我只是像下面这样使用
mutate {rename => ["latitude", "[location][lat]"]}
mutate {rename => ["longitude", "[location][lon]"]}
下面是使用kibana开发工具解决问题的方法,但它无论如何都不起作用
PUT _template/geo-test
{
"order: 0,
"index_patterns": "geo-test",
"mappings": {
"_defaults_": {
"properties": {
"location": {
"type": "geo_point"
}
}
}
}
}