Geo_point logging from python to elasticsearch

Hi folks,
I am trying for a while to log geo_point (not geo_ip) events so i could see them in Kibana using the tilemap feature.
this prooves difficult. this is a simplified version of the index call i'm using:

log_data = {"name": name,
    "Location": Latitude + "," + Longitude}
elf._es.index(index=self._index_name, doc_type=log_type, body=json.dumps(log_data))

but Location always seems to be mapped into a regular string.

What should I do?

btw, i'm not the only one

Have you set the index's mapping to geo_point for the Location field? ES won't recognize any "x,y" string as a geo_point.


I'm not familiar with the python client, but generally for Geo-points you need to define an explicit mapping, since that data type cannot be automatically detected with dynamic mapping (see here for more info on how to do this via the REST interface). You can either add the mapping for that particular field at index creation time or later using the Put Mapping Api. In this case it is important that you havent already indexed any document containing that field, otherwise it will already have been mapped automatically to some data type. How this translates to the Python client Api I'm not exactly sure, but it should be pretty straight forward.

1 Like

thanks, that helped a lot!

1 Like