Elastic Search Bounding Box format as Well-Known Text

There are numerous formats available to pass a geo bounding box to the elastic search API. One of those methods in the bounding box as well-know text or WKT for short. For what ever reason I find string easier to pass and manage in redux state, so I’m using the well-know text. Now I couldn’t find the ordering of the polygon in the string, so here it is:

"filter": {
"geo_bounding_box": {
"pin.location": {
"wkt": "BBOX (-74.1, -71.12, 40.73, 40.01)"
the order of the coordinates is:
right, left, top, bottom (assuming you're looking at a standard map, north at the top, east on the left)
min longitude, max longitude, max latitude, min latitude
west bound, east bound, north bound, south bound

If you find this documented somewhere else please let me know. There are some edge cases I haven’t tested like when a bounding box overlaps the prime meridian and equator. I’ve saved this mostly for my memory and reference, I hope someone else finds it useful. I’ll try to update if I find anything different.

Leave a Reply

Your email address will not be published. Required fields are marked *