/// <summary> /// The distance to include hits in the filter. /// </summary> public GeoDistanceFilter <T> Distance(double?distance, DistanceUnit distanceUnit) { if (!distance.HasValue) { return(this); } return(Distance(distance.AsString() + distanceUnit.AsString())); }
private Sort <T> AddGeoDistancePart(string geoField, DistanceUnit unit, SortDirection order = SortDirection.@default) { var fieldParams = new List <string>(); fieldParams.Add("'unit': {0}".AltQuoteF(unit.AsString().Quotate())); if (order != SortDirection.@default) { fieldParams.Add("'order': {0}".AltQuoteF(order.AsString().Quotate())); } fieldParams.Add(geoField); RegisterJsonPart("{{ '_geo_distance': {{ {0} }} }}", fieldParams.JoinWithComma()); return(this); }
/// <summary> /// The unit the ranges are provided in. Defaults to km. Can also be mi, miles, in, inch, yd, yards, kilometers, mm, millimeters, cm, centimeters, m or meters. /// </summary> public GeoDistanceFacet <T> Unit(DistanceUnit unit = Queries.DistanceUnit.km) { RegisterJsonPart("'unit': {0}", unit.AsString().Quotate()); return(this); }