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.
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"
]
}
}
}
}
}
}
}
}
}
}
}