# Geo\_distance sort shapes

**URL:** https://discuss.elastic.co/t/geo-distance-sort-shapes/74112
**Category:** Elasticsearch
**Created:** [February 6, 2017, 7:17pm UTC](https://discuss.elastic.co/t/geo-distance-sort-shapes/74112 "2017-02-06T19:17:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![juanpujol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juanpujol/32/15087_2.png) [@juanpujol](https://discuss.elastic.co/u/juanpujol)
#### Post date: [February 6, 2017, 7:17pm UTC](https://discuss.elastic.co/t/geo-distance-sort-shapes/74112/1 "2017-02-06T19:17:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [February 7, 2017, 8:29am UTC](https://discuss.elastic.co/t/geo-distance-sort-shapes/74112/2 "2017-02-07T08:29:44Z")

</div>

Hey,

sorting on shapes is currently not possible, see [here](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/geo-shape.html#_sorting_and_retrieving_index_shapes)

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

---

<div class="post-metadata">

### Author: ![juanpujol](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/juanpujol/32/15087_2.png) [@juanpujol](https://discuss.elastic.co/u/juanpujol)
#### Post date: [February 7, 2017, 3:45pm UTC](https://discuss.elastic.co/t/geo-distance-sort-shapes/74112/3 "2017-02-07T15:45:35Z")

</div>

Thank you @spinscale this is a great help.

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

---

<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: [March 7, 2017, 3:45pm UTC](https://discuss.elastic.co/t/geo-distance-sort-shapes/74112/4 "2017-03-07T15:45:43Z")

</div>

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