Elasticsearch Geo search problem (maybe bug)


(dave padovano) #1

I'm experiencing some very strange behavior from Elasticsearch. I am using geo_bounding_box to search the area visible in Google Maps. I have data in New York and San Fransisco. New York behaves as expected. San Fransisco does not, which is confusing the shit out of me.

When searching in San Fransisco, I have to invert the longitude for east and west in order for data to be returned.

Searching in New York works just fine

// New York
"geo_bounding_box" : {
    "location.coordinates": {
        "top_right": [40.75595545633613,-73.85303608398436],
        "bottom_left": [40.64820096366504,-74.03156391601561]
    }
}

// San Fransisco (Normal)
"geo_bounding_box": {
    "location.coordinates": {
        "top_right": [37.79734048601642,-122.39438402099609],
        "bottom_left": [37.7692568462339,-122.4390159790039]
    }
}

// San Fransisco (Normal)
"geo_bounding_box": {
    "location.coordinates": {
        "top_right": [37.79734048601642,-122.39438402099609],
        "bottom_left": [37.7692568462339,-122.4390159790039]
    }
}

As you can see, swapping the longitude values returns results but it does not make any sense because we are searching outside of the bounding box.

I am using elasticsearch Version: 1.4.4

[EDIT] This is an example of geo data stored in the San Fransisco area

"location": {
    "coordinates": [37.7876027, -122.4215609],
    "type": "Point"
 }

(Christoph) #2

Hi,

not sure how you defined your mapping, but when indexing geopoints with as array the format according to the documentation it [lon, lat], so your SF point would be [-122.42, 37.7876]. Of course the order in the query would also have to be changed. This is the coordinate order definet in GeoJson.


(system) #3