是否可以按_geo_distance
对NEST库进行弹性搜索排序?我无法找到任何支持。
做我想要的原始json是:
"sort": [
{
"_geo_distance": {
"position": {
"lat": 59.3389428,
"lon": 18.0761637
},
"order": "asc",
"unit": "m",
"distance_type": "plane"
}
}
]
答案 0 :(得分:4)
var results = client.Search<object>(sd => sd
.SortGeoDistance(d => d
.OnField("position")
.Unit(GeoUnit.Miles)
.DistanceType(GeoDistance.Plane)
.PinTo(Lat: 59.3389428, Lon: 18.0761637)
.Ascending());
答案 1 :(得分:0)
var search2 = _client.Search < Person > (s => s
.Sort(s => s
.GeoDistance(g => g
.Field("location1")
.Order(SortOrder.Ascending)
.DistanceType(GeoDistanceType.Plane)
.Points(search1.Geocoord)
)
)
)