Skip to content

Commit 8673068

Browse files
committed
Merge pull request #353 from tdctaz/change-geo-distance-facet-to-double
Change range on geodistance to double
2 parents d931a5b + 9b33741 commit 8673068

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/Nest.Tests.Unit/Search/Facets/GeoDistanceFacetJson.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public void TestGeoDistance()
1818
.OnValueField(f=>f.Origin)
1919
.PinTo(Lat: 40, Lon: -70)
2020
.Ranges(
21-
r=>r.To(10),
21+
r=>r.To(0.5),
22+
r=>r.From(0.5).To(10),
2223
r=>r.From(10).To(20),
2324
r=>r.From(20).To(100),
2425
r=>r.From(100)
@@ -32,10 +33,11 @@ public void TestGeoDistance()
3233
""origin"" : ""40, -70"",
3334
value_field: ""origin"",
3435
""ranges"" : [
35-
{ ""to"" : 10 },
36-
{ ""from"" : 10, ""to"" : 20 },
37-
{ ""from"" : 20, ""to"" : 100 },
38-
{ ""from"" : 100 }
36+
{ ""to"" : 0.5 },
37+
{ ""from"" : 0.5, ""to"" : 10.0 },
38+
{ ""from"" : 10.0, ""to"" : 20.0 },
39+
{ ""from"" : 20.0, ""to"" : 100.0 },
40+
{ ""from"" : 100.0 }
3941
]
4042
}
4143
}

src/Nest/DSL/Facets/GeoDistanceFacetDescriptor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class GeoDistanceFacetDescriptor
2222

2323
internal string _ValueScript { get; set; }
2424

25-
internal IEnumerable<Range<int>> _Ranges { get; set; }
25+
internal IEnumerable<Range<double>> _Ranges { get; set; }
2626

2727
internal GeoUnit? _GeoUnit { get; set; }
2828

@@ -99,12 +99,12 @@ public GeoDistanceFacetDescriptor<T> DistanceType(GeoDistance distance)
9999
this._GeoDistance = distance;
100100
return this;
101101
}
102-
public GeoDistanceFacetDescriptor<T> Ranges(params Func<Range<int>, Range<int>>[] ranges)
102+
public GeoDistanceFacetDescriptor<T> Ranges(params Func<Range<double>, Range<double>>[] ranges)
103103
{
104-
var newRanges = new List<Range<int>>();
104+
var newRanges = new List<Range<double>>();
105105
foreach (var range in ranges)
106106
{
107-
var r = new Range<int>();
107+
var r = new Range<double>();
108108
newRanges.Add(range(r));
109109
}
110110
this._Ranges = newRanges;

0 commit comments

Comments
 (0)