Skip to content

Commit ceba7cf

Browse files
committed
Handle "NaN" in sampling fields
Fixes #5007
1 parent 7326738 commit ceba7cf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Nest/Aggregations/AggregateFormatter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,8 @@ private IAggregate GetExtendedStatsAggregate(ref JsonReader reader, IJsonFormatt
635635
extendedStatsMetric.SumOfSquares = reader.ReadNullableDouble();
636636
reader.ReadNext(); // ,
637637

638+
var formatter = new NullableStringDoubleFormatter();
639+
638640
while (reader.GetCurrentJsonToken() != JsonToken.EndObject)
639641
{
640642
var propertyName = reader.ReadPropertyNameSegmentRaw();
@@ -656,13 +658,13 @@ private IAggregate GetExtendedStatsAggregate(ref JsonReader reader, IJsonFormatt
656658
extendedStatsMetric.VariancePopulation = reader.ReadNullableDouble();
657659
break;
658660
case 4:
659-
extendedStatsMetric.VarianceSampling = reader.ReadNullableDouble();
661+
extendedStatsMetric.VarianceSampling = formatter.Deserialize(ref reader, formatterResolver);
660662
break;
661663
case 5:
662664
extendedStatsMetric.StdDeviationPopulation = reader.ReadNullableDouble();
663665
break;
664666
case 6:
665-
extendedStatsMetric.StdDeviationSampling = reader.ReadNullableDouble();
667+
extendedStatsMetric.StdDeviationSampling = formatter.Deserialize(ref reader, formatterResolver);
666668
break;
667669
}
668670
}

src/Nest/Aggregations/Metric/ExtendedStats/ExtendedStatsAggregate.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.Runtime.Serialization;
6+
using Nest.Utf8Json;
67

78
namespace Nest
89
{
@@ -73,9 +74,11 @@ public class StandardDeviationBounds
7374
public double? UpperPopulation { get; set; }
7475

7576
[DataMember(Name = "lower_sampling")]
77+
[JsonFormatter(typeof(NullableStringDoubleFormatter))]
7678
public double? LowerSampling { get; set; }
7779

7880
[DataMember(Name = "upper_sampling")]
81+
[JsonFormatter(typeof(NullableStringDoubleFormatter))]
7982
public double? UpperSampling { get; set; }
8083
}
8184
}

0 commit comments

Comments
 (0)