I am trying to import LAT, LNG columns from MySQL into ES Geo Point type. At the moment, it does import data but in separate fields. I am using following Logstash script:
input {
jdbc {
jdbc_driver_library => "C:\Users\x64\Desktop\ELK\logstash-6.1.3\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 LOCATION_LAT, LOCATION_LNG
FROM
fbk_core"
}
}
filter {
if [LOCATION_LAT] and [LOCATION_LNG] {
mutate {
rename => {
"LOCATION_LNG" => "[location][lon]"
"LOCATION_LAT" => "[location][lat]"
}
}
}
# mutate {
# convert => [ "[geoip][location]", "float" ]
# }
}
output{
elasticsearch {
hosts => ["localhost:9200"]
index => "geoindex"
# document_id => "%{URI}"
# document_type => "my_type"
# manage_template => true
# user => "elastic"
# password => "changeme"
}
stdout { codec => rubydebug { metadata => true } }
# stdout { codec => dots }
}
Please suggest changes that could convert two fields into Geo Point data type. Also I am confused about whether should I create an index first then mapping and finally import the data or just import the data and ES would take care of the rest.
Thank you so much in advance !
Best,
Ayub