Can not find geoshape in aggregation of Nest 6.8 to 7.8.1

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. :slight_smile:

        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"
                              ]
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
1 Like

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
  2. Geo queries
1 Like
[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.
.

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