# Howto map city (non-IP) to geospatial in ES

**URL:** <https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341>\
**Category:** Elasticsearch\
**Created:** [August 13, 2015, 6:26pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341 "2015-08-13T18:26:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrankC](https://avatars.discourse-cdn.com/v4/letter/f/ed655f/32.png) [@FrankC](https://discuss.elastic.co/u/FrankC)\
**Post date:** [August 13, 2015, 6:26pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/1 "2015-08-13T18:26:06Z")

</div>

Hi,

I have loaded IP data to ES for geospatial visualization in Kibana. Awesome!

Is there a way to map non-IP data (e.g. City, addresses, etc) to ES for geospatial queries?

Frank.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 13, 2015, 8:52pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/2 "2015-08-13T20:52:33Z")

</div>

You would need a database with that information to add a geopoint, but then you'd have to merge those together outside of ES.

---

<div class="post-metadata">

**Author:** ![FrankC](https://avatars.discourse-cdn.com/v4/letter/f/ed655f/32.png) [@FrankC](https://discuss.elastic.co/u/FrankC)\
**Post date:** [August 13, 2015, 9:36pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/3 "2015-08-13T21:36:33Z")

</div>

I am not sure I understood.

Logstash comes with the GeoLiteCity database with these fields.  
From the docs:  
For the built-in GeoLiteCity database, the following are available: city\_name, continent\_code, country\_code2, country\_code3, country\_name, dma\_code, ip, latitude, longitude, postal\_code, region\_name and timezone.

Example row from the GeoLiteCity db  
2245,"US","IL","Itasca","60143",41.9750,-88.0073,602,630

So if my data file has city="Itasca"... can I use the geoip filter like this?

geoip  
{  
source =\> "city"  
target =\> "geoip"  
add\_field =\> ["[geoip][coordinates]", "%{[geoip][longitude]}" ]  
add\_field =\> ["[geoip][coordinates]", "%{[geoip][latitude]}" ]  
}

mutate { convert =\> ["[geoip][coodinates]", "float"] }

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 13, 2015, 9:55pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/4 "2015-08-13T21:55:52Z")

</div>

Nope because it expects an IP, not a city name.

---

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loren/32/44942_2.png) [@loren](https://discuss.elastic.co/u/loren)\
**Post date:** [August 13, 2015, 10:24pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/5 "2015-08-13T22:24:05Z")

</div>

I wrote some code a while back that integrates city/state info from [Geonames](http://www.geonames.org) into Elasticsearch geopoints. The project is here: [https://github.com/GSA/jobs\_api](https://github.com/GSA/jobs_api)

The most relevant files for your question are [https://github.com/GSA/jobs\_api/blob/master/app/models/geoname.rb](https://github.com/GSA/jobs_api/blob/master/app/models/geoname.rb) and [https://github.com/GSA/jobs\_api/blob/master/lib/importers/geonames\_data.rb](https://github.com/GSA/jobs_api/blob/master/lib/importers/geonames_data.rb).

In my case I have job openings, and each one is tied to a city (or multiple cities). I use Geonames to resolve the city to a geopoint and then store that geopoint in the job opening document. Then Elasticsearch `geo_distance` sorting lets me find the nearest job opening to the searcher's geo location.

---

<div class="post-metadata">

**Author:** ![FrankC](https://avatars.discourse-cdn.com/v4/letter/f/ed655f/32.png) [@FrankC](https://discuss.elastic.co/u/FrankC)\
**Post date:** [August 14, 2015, 2:08am UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/6 "2015-08-14T02:08:35Z")

</div>

Thanks! I will take a look.

---

<div class="post-metadata">

**Author:** ![FrankC](https://avatars.discourse-cdn.com/v4/letter/f/ed655f/32.png) [@FrankC](https://discuss.elastic.co/u/FrankC)\
**Post date:** [August 14, 2015, 2:11am UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/7 "2015-08-14T02:11:51Z")

</div>

I figured. Hopefully an enhancement down the road since the data is available in the geolite db.

---

<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:** [July 5, 2017, 11:55pm UTC](https://discuss.elastic.co/t/howto-map-city-non-ip-to-geospatial-in-es/27341/8 "2017-07-05T23:55:53Z")

</div>


