# How to enrich geolocation queries on-the-fly?

**URL:** <https://discuss.elastic.co/t/how-to-enrich-geolocation-queries-on-the-fly/87623>\
**Category:** Elasticsearch\
**Created:** [May 30, 2017, 7:23pm UTC](https://discuss.elastic.co/t/how-to-enrich-geolocation-queries-on-the-fly/87623 "2017-05-30T19:23:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean\_lindo](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sean\_lindo](https://discuss.elastic.co/u/sean_lindo)\
**Post date:** [May 30, 2017, 7:23pm UTC](https://discuss.elastic.co/t/how-to-enrich-geolocation-queries-on-the-fly/87623/1 "2017-05-30T19:23:19Z")

</div>

Hi all,

There are two use cases that I'm primarily interested in:

- Query documents by one or more zip codes

- Query documents by metropolitan area, [which is essentially a shape](https://catalog.data.gov/dataset/tiger-line-shapefile-2015-nation-u-s-current-metropolitan-statistical-area-micropolitan-statist)

Instead of our users memorizing lat/long coordinates, I'd like to enrich their queries on the fly with geolocation data. Are there provisions baked into Elasticsearch for this, or should I just perform a database (or cache) lookup and retrieve the coordinates that way?

I'm just not sure if there's a way to index this in Elasticsearch and define the appropriate transformations somehow or not.

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [May 31, 2017, 8:47am UTC](https://discuss.elastic.co/t/how-to-enrich-geolocation-queries-on-the-fly/87623/2 "2017-05-31T08:47:39Z")

</div>

> [@sean\_lindo](#):
>
> I'd like to enrich their queries on the fly with geolocation data

What geolocation data would you wish to enrich their query with? For example, their current lat/lon, the multipolygon that corresponds to their hometown (retrieved from their user profile in you system)?

---

<div class="post-metadata">

**Author:** ![sean\_lindo](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sean\_lindo](https://discuss.elastic.co/u/sean_lindo)\
**Post date:** [May 31, 2017, 12:16pm UTC](https://discuss.elastic.co/t/how-to-enrich-geolocation-queries-on-the-fly/87623/3 "2017-05-31T12:16:36Z")

</div>

For example,

If they pass in “30044”, I would like to enrich the query with the actual lat/long coordinates for that ZIP code. If the pass in something like “Atlanta Metro Area” I would like to enrich that with the multipolygon that corresponds to the Atlanta Metro area.

---

<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:** [June 28, 2017, 12:16pm UTC](https://discuss.elastic.co/t/how-to-enrich-geolocation-queries-on-the-fly/87623/4 "2017-06-28T12:16:39Z")

</div>

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