gpt4 book ai didi

mysql - 将地理点(Lat、Lng)从 MySQL 导入 Elasticsearch

转载 作者:行者123 更新时间:2023-11-29 17:54:50 27 4
gpt4 key购买 nike

我正在尝试使用以下 Logstash 脚本(ELK v 6.22)将数据从 MySQL 导入弹性索引:

input {
jdbc {
jdbc_driver_library => "E:\ELK 6.22\logstash-6.2.2\bin\mysql-connector-java-5.1.45-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/fbk"
jdbc_user => "root"
jdbc_password => ""
statement => "SELECT fbk_repeat._URI AS URI, _SUBMISSION_DATE AS SUBMISSION_DATE, DEVICEID, LOCATION_LAT, LOCATION_LNG, SECTOR, COMMENTS, ACTION_TAKEN, PURPOSE
FROM
fbk_core
INNER JOIN fbk_repeat ON fbk_core._URI = fbk_repeat._PARENT_AURI"
}
}



filter {

# mutate { convert => {"LOCATION_LAT" => "float"} }
# mutate { convert => {"LOCATION_LNG" => "float"} }
# mutate { rename => {"LOCATION_LAT" => "[location][lat]"} }
# mutate { rename => {"LOCATION_LNG" => "[location][lon]"} }

mutate {
# Location and lat/lon should be used as is, this is as per logstash documentation
# Here we are tying to create a two-dimensional array in order to save data as per Logstash documentation

add_field => { "[location][lat]" => [ "%{LOCATION_LAT}" ] }
add_field => { "[location][lon]" => [ "%{LOCATION_LNG}" ] }
convert => [ "[location]", "float" ]
}


# date {
# locale => "eng"
# match => ["_SUBMISSION_DATE", "yyyy-MM-dd HH:mm:ss", "ISO8601"]
# target => "SUBMISSION_DATE"
# }

}

output{
elasticsearch {
hosts => ["localhost:9200"]
index => "feedback"
document_id => "%{URI}"
document_type => "feedbackdata"
manage_template => true

# user => "elastic"
# password => "changeme"


}
stdout { codec => rubydebug { metadata => true } }
# stdout { codec => dots }
}

导入数据后,我在 Kibana 中找不到任何能够将数据绘制到 map 中的地理点字段,任何人都可以指导出什么问题了。

谢谢!

数据 enter image description here

最佳答案

Elasticsearch 可以自动进行映射,但不能针对所有字段。您应该像这样设置映射:

PUT index
{
"mappings": {
"type": {
"properties": {
"location": {
"properties": {
"coordinates": {
"type": "geo_point"
}
}
},
"field": {
"properties": {
"date": {
"format": "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
"type": "date"
}
}
}
}
}
}
}

调整它来处理您的数据。

不要忘记创建 index pattern在基巴纳。

关于mysql - 将地理点(Lat、Lng)从 MySQL 导入 Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48944085/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com