Importing Geo Point from MySQL LAT LNG ELK 6.22

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

Mappings must be set for ES to understand that a field is a geo_point field. This can be done

  • in the index creation request,
  • after index creation as long as mappings of existing fields isn't modified, or
  • when the index is created if a matching index template has been put in place.

Have you read https://www.elastic.co/blog/geoip-in-the-elastic-stack?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.