# ElasticSearch geo\_bounding\_box coordinate format

**URL:** <https://discuss.elastic.co/t/elasticsearch-geo-bounding-box-coordinate-format/8176>\
**Category:** Elasticsearch\
**Created:** [June 21, 2012, 12:57am UTC](https://discuss.elastic.co/t/elasticsearch-geo-bounding-box-coordinate-format/8176 "2012-06-21T00:57:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffLocke](https://avatars.discourse-cdn.com/v4/letter/j/edb3f5/32.png) [@JeffLocke](https://discuss.elastic.co/u/JeffLocke)\
**Post date:** [June 21, 2012, 12:57am UTC](https://discuss.elastic.co/t/elasticsearch-geo-bounding-box-coordinate-format/8176/1 "2012-06-21T00:57:08Z")

</div>

I was following the guide online to represent coordinates as "lat, lng" but  
it doesnt seem to be working until I flip everything around to "lng, lat".  
I even have to flip around top\_left and bottom\_right in order for the query  
to work.

Is anyone experiencing the same problem? Clearly this is not how the  
documentation says to use it, but it's only working when I format it this  
way.

Rails format

def self.search(params)  
tire.search( page: params[:page], per\_page: 2 ) do  
query { all }  
filter :geo\_bounding\_box, location: { top\_left: "  
-121.88596979687497, 37.33588487375733", bottom\_right: "  
-122.43528620312497, 37.553946238118264" }  
end  
end

CURL format

curl -X GET  
"[http://localhost:9200/articles/article/\_search?page=&per\_page=2&size=2&pretty=true](http://localhost:9200/articles/article/_search?page=&per_page=2&size=2&pretty=true)"  
-d  
'{"query":{"match\_all":{}},"facets":{"condition":{"terms":{"field":"condition","size":10,"all\_terms":false}}},"filter":{"geo\_bounding\_box":{"location":{"top\_left":"  
-121.88596979687497, 37.33588487375733","bottom\_right":"  
-122.43528620312497, 37.553946238118264"}}},"size":2}'

Console response

{  
"took" : 1,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 169,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "articles",  
"\_type" : "article",  
"\_id" : "4f72bc7d0bdb820f02000002",  
"\_score" : 1.0, "\_source" : {"content":"words  
here!","location":[37.444995,-122.160628],"name":"harro"}  
}, {  
"\_index" : "articles",  
"\_type" : "article",  
"\_id" : "4fdf0cf20bdb82336c000002",  
"\_score" : 1.0, "\_source" : {"content":"Run of the  
mill","location":[37.33588487375733,-121.88596979687497],"name":"Billy Bob"}  
} ]  
},  
"facets" : {  
"condition" : {  
"\_type" : "terms",  
"missing" : 5597,  
"total" : 0,  
"other" : 0,  
"terms" : []  
}  
}

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [June 21, 2012, 1:52am UTC](https://discuss.elastic.co/t/elasticsearch-geo-bounding-box-coordinate-format/8176/2 "2012-06-21T01:52:02Z")

</div>

String representation of geo point and array representation of geo point  
are using different formats. The string representation is using "lat,lon"  
format while array representation is using [lon, lat] format. You are using  
strings in query and arrays in data. That's why you are getting  
strange results. See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Wednesday, June 20, 2012 8:57:08 PM UTC-4, Jeff Locke wrote:

> I was following the guide online to represent coordinates as "lat, lng"  
> but it doesnt seem to be working until I flip everything around to "lng,  
> lat". I even have to flip around top\_left and bottom\_right in order for the  
> query to work.
> 
> Is anyone experiencing the same problem? Clearly this is not how the  
> documentation says to use it, but it's only working when I format it this  
> way.
> 
> Rails format
> 
> def self.search(params)  
> tire.search( page: params[:page], per\_page: 2 ) do  
> query { all }  
> filter :geo\_bounding\_box, location: { top\_left: "  
> -121.88596979687497, 37.33588487375733", bottom\_right: "  
> -122.43528620312497, 37.553946238118264" }  
> end  
> end
> 
> CURL format
> 
> curl -X GET "  
> [http://localhost:9200/articles/article/\_search?page=&per\_page=2&size=2&pretty=true](http://localhost:9200/articles/article/_search?page=&per_page=2&size=2&pretty=true)"  
> -d  
> '{"query":{"match\_all":{}},"facets":{"condition":{"terms":{"field":"condition","size":10,"all\_terms":false}}},"filter":{"geo\_bounding\_box":{"location":{"top\_left":"  
> -121.88596979687497, 37.33588487375733","bottom\_right":"  
> -122.43528620312497, 37.553946238118264"}}},"size":2}'
> 
> Console response
> 
> {  
> "took" : 1,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 169,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "articles",  
> "\_type" : "article",  
> "\_id" : "4f72bc7d0bdb820f02000002",  
> "\_score" : 1.0, "\_source" : {"content":"words  
> here!","location":[37.444995,-122.160628],"name":"harro"}  
> }, {  
> "\_index" : "articles",  
> "\_type" : "article",  
> "\_id" : "4fdf0cf20bdb82336c000002",  
> "\_score" : 1.0, "\_source" : {"content":"Run of the  
> mill","location":[37.33588487375733,-121.88596979687497],"name":"Billy Bob"}  
> } ]  
> },  
> "facets" : {  
> "condition" : {  
> "\_type" : "terms",  
> "missing" : 5597,  
> "total" : 0,  
> "other" : 0,  
> "terms" :   
> }  
> }

---

<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 6, 2017, 3:23am UTC](https://discuss.elastic.co/t/elasticsearch-geo-bounding-box-coordinate-format/8176/3 "2017-07-06T03:23:13Z")

</div>


