Translating zipcode to long/lat in query?

HI,
I have an index with documents that contain a geo_point field.
I want to have a query where the user gives a zipcode, I translate it to long/lat based on some static mapping and return relevant results with the geo_distance query. I don't want the client side to do the translation and submit long/lats.

Can it be done? I looked at ingest node scripting to alter the query, but couldn't find a processor that can do a key-value lookup on another index (that will hold all mappings) or read mapping from a file on disk.
Can a painless (or other language) script query an ES index?

Any other ideas?

Thanks!
Zach

Ingest node is for preparing documents to index, not queries to run.

You'd need to get hold of the data that has coordinates for each zipcode and you could put that into elasticsearch and then run a preliminary query to get the coordinates for a given postcode. Instead you could use some custom server-side logic to cache all the zipcodes in memory and look coordinates up using that.

Yes, it can be done.

It is a special case of my reference plugin https://github.com/jprante/elasticsearch-analysis-reference where a new field type could be introduced to translate a zip code to a geo field. The translation could be implemented by a lookup of geo coordinates stored in a zip code index.

thanks! I'll have a look.
Does the plugin also work with ES 5.x? (GIthub only mentioned 2.x)

Note, the reference plugin is not ready for your use case "referencing lat/lon from given zip code". You'd have to implement such a plugin.

ES 5.x is work in progress.

If you want to see a preview release, I have a plugin bundle ready for ES 5.1.1 of all my analysis plugins, where the reference plugin is already part of. See https://github.com/jprante/elasticsearch-plugin-bundle

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