# Can not find geoshape in aggregation of Nest 6.8 to 7.8.1

**URL:** <https://discuss.elastic.co/t/can-not-find-geoshape-in-aggregation-of-nest-6-8-to-7-8-1/245011>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 14, 2020, 1:06pm UTC](https://discuss.elastic.co/t/can-not-find-geoshape-in-aggregation-of-nest-6-8-to-7-8-1/245011 "2020-08-14T13:06:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dat\_Le\_Tien](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dat_le_tien/32/46835_2.png) [@Dat\_Le\_Tien](https://discuss.elastic.co/u/Dat_Le_Tien)\
**Post date:** [August 14, 2020, 1:06pm UTC](https://discuss.elastic.co/t/can-not-find-geoshape-in-aggregation-of-nest-6-8-to-7-8-1/245011/1 "2020-08-14T13:06:18Z")

</div>

Hello. Can anyone help me to anwser the question. My below script can work in knibana. But when I convert it to c# code by Nest. I can not find GeoShape in Aggregation container. It's only available in query. Is it possible to use Geoshape in Aggregation.

Thanks all. 🙂

```auto
        GET /photographer/_search
        {
          "size": 0,
          "aggs": {
            "active_photographer": {
              "filter": {
                "bool": {
                  "should": [
                    {
                      "terms": {
                        "approvalStatus": [
                          2,
                          5
                        ]
                      }
                    },
                    {
                      "term": {
                        "shootTypes.hidden": "false"
                      }
                    },
                    {
                      "term": {
                        "stripeconnected": "true"
                      }
                    },
                    {
                      "term": {
                        "availabilityCalendarDays.duration": ""
                      }
                    },
                    {
                      "geo_shape": {
                        "_name": "named_query",
                        "boost": 1.1,
                        "ignore_unmapped": true,
                        "location": {
                          "shape": {
                            "type": "polygon",
                            "coordinates": [
                              [
                                [
                                  -78.471063,
                                  35.97172800000001
                                ],
                                [
                                  -78.8190489,
                                  35.97172800000001
                                ],
                                [
                                  -78.8190489,
                                  35.7158079
                                ],
                                [
                                  -78.471063,
                                  35.7158079
                                ],
                                [
                                  -78.471063,
                                  35.97172800000001
                                ]
                              ]
                            ]
                          },
                          "relation": "intersects"
                        }
                      }
                    }
                  ]
                }
              },
              "aggs": {
                "rings": {
                  "geo_distance": {
                    "field": "geoPosition",
                    "origin": {
                      "lat": 35.648601,
                      "lon": -78.837376
                    },
                    "unit": "mi",
                    "distance_type": "arc",
                    "ranges": [
                      {
                        "to": 100
                      }
                    ]
                  },
                  "aggs": {
                    "cities": {
                      "terms": {
                        "field": "travelDistance.city.keyword",
                        "min_doc_count": 7
                      },
                      "aggs": {
                        "min_distance_photographer_in_cities": {
                          "avg": {
                            "script": {
                              "source": "doc['geoPosition'].arcDistance(params.ref_lat, params.ref_lon) * 0.001",
                              "params": {
                                "ref_lat": 35.7795897,
                                "ref_lon": -78.6381787
                              }
                            }
                          }
                        },
                        "aggs": {
                          "top_hits": {
                            "script_fields": {
                              "distance": {
                                "script": {
                                  "source": "doc['geoPosition'].arcDistance(params.ref_lat, params.ref_lon) * 0.001",
                                  "params": {
                                    "ref_lat": 35.7795897,
                                    "ref_lon": -78.6381787
                                  }
                                }
                              }
                            },
                            "sort": [
                              {
                                "rating": {
                                  "order": "desc"
                                }
                              }
                            ],
                            "_source": {
                              "includes": [
                                "travelDistance",
                                "userId",
                                "location",
                                "geoPosition",
                                "radius",
                                "availabilityCalendarDays.duration"
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }

```

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [August 17, 2020, 12:51am UTC](https://discuss.elastic.co/t/can-not-find-geoshape-in-aggregation-of-nest-6-8-to-7-8-1/245011/2 "2020-08-17T00:51:39Z")

</div>

There isn't a geo shape aggregation, I think you mean geo distance aggregation, based on the example? Take a look at the usage docs:

1. [Geo Distance aggregation](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/geo-distance-aggregation-usage.html)
2. [Geo queries](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/geo-queries.html)

---

<div class="post-metadata">

**Author:** ![Dat\_Le\_Tien](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dat_le_tien/32/46835_2.png) [@Dat\_Le\_Tien](https://discuss.elastic.co/u/Dat_Le_Tien)\
**Post date:** [August 17, 2020, 7:44am UTC](https://discuss.elastic.co/t/can-not-find-geoshape-in-aggregation-of-nest-6-8-to-7-8-1/245011/3 "2020-08-17T07:44:51Z")

</div>

```auto
[quote="Dat_Le_Tien, post:1, topic:245011"]
`geo_shape`
[/quote]

forloop. I used both in my query in kibaba and it's working.

1. geo_shape to search with radius

2. geo_distance to calculate the distance

But I think so. There was not geo shape in aggregation with NEST in c#. Thanks for reply.
.

```

---

<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:** [September 14, 2020, 7:44am UTC](https://discuss.elastic.co/t/can-not-find-geoshape-in-aggregation-of-nest-6-8-to-7-8-1/245011/4 "2020-09-14T07:44:53Z")

</div>

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