Jonas Stensved February 2016

How can I sort by _geo_distance in NEST for Elasticsearch?

Is it possible to sort by _geo_distance with the NEST library for Elastic Search? I can't find any support for it.

The raw json for doing what I want is:

"sort": [
      {
         "_geo_distance": {
            "position": {
               "lat": 59.3389428,
               "lon": 18.0761637
            },
            "order": "asc",
            "unit": "m",
            "distance_type": "plane"
         }
      }
   ]

Answers


bittusarkar February 2016

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());

Post Status

Asked in February 2016
Viewed 2,608 times
Voted 10
Answered 1 times

Search




Leave an answer