GeoDistance Aggregation is not working with Nested Aggregation

Hello all,

I'm using GeoDistance Aggregation on a nested field so it is wrapped around a nested aggregation. This query is being run ES 1.6.0 and encountering an exception which I'm unable to solve. Please also take a look at the query if it is the right way to use GeoDistance Aggregation.

Query:

 {
   "aggs": {
      "nested_geodistance": {
         "nested": {
            "path": "addresses"
         },
         "aggs": {
            "per_ring": {
               "geo_distance": {
                  "field": "addresses.location",
                  "unit": "km",
                  "orgin": {
                     "lat": 56.78,
                     "lon": -12.34
                  },
                  "ranges": [
                     {
                        "from": 100,
                        "to": 200
                     }
                  ]
               }
            }
         }
      }
   }
}

After executing this query I'm getting below exception:

Parse Failure [Unexpected token START_OBJECT in [per_ring].]]; }{[F8SeZ5RjR_KpSnvWBOSg7w][prod-contacts-0][4]: RemoteTransportException

I have revisited my query multiple times but unable to figure out what's wrong with my aggregation name.
Please let me know if further information is needed.

Thanks,
Ayush

This is the issue. This should be origin. Not sure why the error is so cryptic though. I've raised a bug to fix the error message to be something more helpful: Cryptic error message when mis-spelling a field in geo-distance aggregation · Issue #12391 · elastic/elasticsearch · GitHub

1 Like

Wow..!! I wonder how I missed that.
Thank you Colin

No worries, it took me a little while to see it :smile: