Skip to content

Commit 4ebcca8

Browse files
authored
Correctly deserialize Percentiles aggregate (#3724)
This commit correctly deserializes percentiles aggegations by closing the object or array in which values are returned. In addition, percentile item values can be nullable, so read as null or double and update PercentileItem to have nullable value. Closes #3715
1 parent 2d6d3d2 commit 4ebcca8

File tree

3 files changed

+660
-3
lines changed

3 files changed

+660
-3
lines changed

src/Nest/Aggregations/AggregateFormatter.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,11 @@ private IAggregate GetPercentilesAggregate(ref JsonReader reader)
325325
metric.Items.Add(new PercentileItem
326326
{
327327
Percentile = double.Parse(propertyName),
328-
Value = reader.ReadDouble()
328+
Value = reader.ReadNullableDouble()
329329
});
330330
}
331+
332+
reader.ReadNext(); // }
331333
}
332334
else
333335
{
@@ -343,10 +345,12 @@ private IAggregate GetPercentilesAggregate(ref JsonReader reader)
343345
metric.Items.Add(new PercentileItem
344346
{
345347
Percentile = percentile,
346-
Value = reader.ReadDouble()
348+
Value = reader.ReadNullableDouble()
347349
});
348350
reader.ReadNext(); // }
349351
}
352+
353+
reader.ReadNext(); // ]
350354
}
351355

352356
return metric;

src/Nest/Aggregations/Metric/Percentiles/PercentilesMetricAggregate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Nest
55
public class PercentileItem
66
{
77
public double Percentile { get; internal set; }
8-
public double Value { get; internal set; }
8+
public double? Value { get; internal set; }
99
}
1010

1111
public class PercentilesAggregate : MetricAggregateBase

0 commit comments

Comments
 (0)