Geo_distance sort shapes


(Juan Pujol) #1

What's the best way to sort by distance documents found by the geo_shape query?

Example, I'm running this query and I'll like to sort the documents found by the distance to the nearest point of a shape.

GET /gsp/_search
{
  "query": {
    "geo_shape": {
      "geometry": { 
        "shape": { 
          "type": "circle", 
          "radius": "100km",
          "coordinates": [-73.995175, 40.724822]
        }
      }
    }
  }
}

Thank you


(Alexander Reelsen) #2

Hey,

sorting on shapes is currently not possible, see here

If you have shapes where can define a central point, you could use geo points, but that of course is just an approximation that is wildly wrong.

--Alex


(Juan Pujol) #3

Thank you @spinscale this is a great help.

I'm going to stick to Mongo to do this for now.


(system) #4

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