55
66namespace Nest
77{
8+ /// <summary> Allows you to sort based on a proximity to one or more <see cref="GeoLocation"/> </summary>
89 public interface IGeoDistanceSort : ISort
910 {
1011 Field Field { get ; set ; }
1112 IEnumerable < GeoLocation > Points { get ; set ; }
1213
14+ /// <summary> The unit to use when computing sort values. The default is m (meters) </summary>
1315 [ JsonProperty ( "unit" ) ]
1416 DistanceUnit ? GeoUnit { get ; set ; }
1517
18+ /// <summary>
19+ /// How to compute the distance. Can either be arc (default), or plane (faster, but
20+ /// inaccurate on long distances and close to the poles).
21+ /// </summary>
1622 [ JsonProperty ( "distance_type" ) ]
1723 GeoDistanceType ? DistanceType { get ; set ; }
24+
25+ /// <summary>
26+ /// Indicates if the unmapped field should be treated as a missing value. Setting it to `true` is equivalent to specifying
27+ /// an `unmapped_type` in the field sort. The default is `false` (unmapped field are causing the search to fail)
28+ /// </summary>
29+ [ JsonProperty ( "ignore_unmapped" ) ]
30+ bool ? IgnoreUnmapped { get ; set ; }
1831 }
1932
33+ /// <inheritdoc cref="IGeoDistanceSort"/>
2034 public class GeoDistanceSort : SortBase , IGeoDistanceSort
2135 {
2236 protected override Field SortKey => "_geo_distance" ;
2337 public Field Field { get ; set ; }
2438 public IEnumerable < GeoLocation > Points { get ; set ; }
39+ /// <inheritdoc cref="IGeoDistanceSort.GeoUnit"/>
2540 public DistanceUnit ? GeoUnit { get ; set ; }
41+ /// <inheritdoc cref="IGeoDistanceSort.DistanceType"/>
2642 public GeoDistanceType ? DistanceType { get ; set ; }
43+ /// <inheritdoc cref="IGeoDistanceSort.IgnoreUnmapped"/>
44+ public bool ? IgnoreUnmapped { get ; set ; }
2745
2846 }
2947
48+ /// <inheritdoc cref="IGeoDistanceSort"/>
3049 public class SortGeoDistanceDescriptor < T > : SortDescriptorBase < SortGeoDistanceDescriptor < T > , IGeoDistanceSort , T > , IGeoDistanceSort
3150 where T : class
3251 {
@@ -36,18 +55,24 @@ public class SortGeoDistanceDescriptor<T> : SortDescriptorBase<SortGeoDistanceDe
3655 IEnumerable < GeoLocation > IGeoDistanceSort . Points { get ; set ; }
3756 DistanceUnit ? IGeoDistanceSort . GeoUnit { get ; set ; }
3857 GeoDistanceType ? IGeoDistanceSort . DistanceType { get ; set ; }
58+ bool ? IGeoDistanceSort . IgnoreUnmapped { get ; set ; }
3959
4060 public SortGeoDistanceDescriptor < T > Points ( params GeoLocation [ ] geoLocations ) => Assign ( a => a . Points = geoLocations ) ;
4161
4262 public SortGeoDistanceDescriptor < T > Points ( IEnumerable < GeoLocation > geoLocations ) => Assign ( a => a . Points = geoLocations ) ;
4363
64+ /// <inheritdoc cref="IGeoDistanceSort.GeoUnit"/>
4465 public SortGeoDistanceDescriptor < T > Unit ( DistanceUnit ? unit ) => Assign ( a => a . GeoUnit = unit ) ;
4566
67+ /// <inheritdoc cref="IGeoDistanceSort.DistanceType"/>
4668 public SortGeoDistanceDescriptor < T > DistanceType ( GeoDistanceType ? distanceType ) => Assign ( a => a . DistanceType = distanceType ) ;
4769
4870 public SortGeoDistanceDescriptor < T > Field ( Field field ) => Assign ( a => a . Field = field ) ;
4971
5072 public SortGeoDistanceDescriptor < T > Field ( Expression < Func < T , object > > objectPath ) => Assign ( a => a . Field = objectPath ) ;
5173
74+ /// <inheritdoc cref="IGeoDistanceSort.IgnoreUnmapped"/>
75+ public SortGeoDistanceDescriptor < T > IgnoreUnmapped ( bool ? ignoreUnmapped = true ) => Assign ( a => a . IgnoreUnmapped = ignoreUnmapped ) ;
76+
5277 }
5378}
0 commit comments