How elasticsearch index Geo-points?

I can't imagine how Elasteicsearch index Geo-points.
Suppose I have 1 million records/documents in my table/index and each document has a geo point (Lat/Lon).
In sql , if I want to find the 10 nearest docs, I need to check all 1 million docs and get all the distnces between my current location and the points in my table, and then sort/extract the nearset places . (distance = sqrt ( x^2 + y^2) and this should be done 1 million times)

But in Elasticsearch it is done so fast !! I know that's impossible to calculate all distances and compare them at times less than 50 milli seconds (according to my current hardware) !!

So , I need to know what is the mechanism of Elasticsearch in indexing Geo points ? That it can find and compare distances so fast?

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