# Importing Geo Point from MySQL LAT LNG ELK 6.22

**URL:** https://discuss.elastic.co/t/importing-geo-point-from-mysql-lat-lng-elk-6-22/121340
**Category:** Logstash
**Created:** [February 24, 2018, 1:32pm UTC](https://discuss.elastic.co/t/importing-geo-point-from-mysql-lat-lng-elk-6-22/121340 "2018-02-24T13:32:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ayub.zafar](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@ayub.zafar](https://discuss.elastic.co/u/ayub.zafar)
#### Post date: [February 24, 2018, 1:32pm UTC](https://discuss.elastic.co/t/importing-geo-point-from-mysql-lat-lng-elk-6-22/121340/1 "2018-02-24T13:32:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [February 27, 2018, 8:08am UTC](https://discuss.elastic.co/t/importing-geo-point-from-mysql-lat-lng-elk-6-22/121340/2 "2018-02-27T08:08:36Z")

</div>

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](https://www.elastic.co/blog/geoip-in-the-elastic-stack)?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 27, 2018, 8:08am UTC](https://discuss.elastic.co/t/importing-geo-point-from-mysql-lat-lng-elk-6-22/121340/3 "2018-03-27T08:08:43Z")

</div>

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