Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch geo-database: geo_distance filter returns geo pins in ellipse not in circle

i have elasticsearch database of geo objects. I want to search the nearest objects around some geo_point in custom distance and then display them on google map. using default elasticsearch filters - geo_distance filter, it works fine, but the problem is that returned pins are in eliptical range, not in circular range (as usually when you search anything in X km RADIUS) maybe screenshots would help to understand.

I don't know where the problem can be, google maps only takes the result that elastic returns - set of pins to display

Does anybody know anything about this issue?

map without filtering

filtered map, the red circle shows actual border of searching

like image 360
Ondrej Avatar asked Jun 14 '12 10:06

Ondrej


2 Answers

When geo points are represented as arrays in elasticsearch they are following GeoJSON format, which is [lon, lat]. So, from elasticsearch perspective, your center pin is not in Paris but just off the coast of Somalia.

like image 141
imotov Avatar answered Oct 12 '22 22:10

imotov


Based on your screenshots I came up with a couple of points in your circle.

Assuming we have centre coordinate of lat:48.853647, lon:2.347894, and a point at lat:48.853647 lon:2.32 (a point at the same lat but further west):

Using distance_type:plane the distance calculated is ~ 3.1km, while using distance_type:arc the distance is ~ 2km.

If we use a different point, lat:48.8717 lon:2.347894 (further north of the centre point, but some lon), using distance_type:plane the distance is ~ 2km and using distance_type:arc it is also ~ 2km.

Consequently if the filtered distance was say 2.5km, then using distance_type:arc would correctly include both points, while using distance_type:plane would only include the northern point, giving the elliptical shape.

like image 34
Chris M Avatar answered Oct 12 '22 22:10

Chris M