From 155348ce32857673b07d059beefddfd6c4e53c2d Mon Sep 17 00:00:00 2001 From: Steve Gordon Date: Thu, 26 Nov 2020 15:26:22 +0000 Subject: [PATCH] Update BoxplotAggregate response In 7.11 the boxplot aggregation response includes two additional properties, lower and upper. I've added these to our type and updated the deserialization to handle these when present. --- src/Nest/Aggregations/AggregateFormatter.cs | 14 ++++++++++++++ .../Metric/Boxplot/BoxplotAggregate.cs | 4 ++++ .../Metric/Boxplot/BoxplotAggregationUsageTests.cs | 2 ++ 3 files changed, 20 insertions(+) diff --git a/src/Nest/Aggregations/AggregateFormatter.cs b/src/Nest/Aggregations/AggregateFormatter.cs index 53404152bf4..ba0fb443610 100644 --- a/src/Nest/Aggregations/AggregateFormatter.cs +++ b/src/Nest/Aggregations/AggregateFormatter.cs @@ -254,6 +254,20 @@ private IAggregate GetBoxplotAggregate(ref JsonReader reader, IReadOnlyDictionar reader.ReadNext(); // "q3" reader.ReadNext(); // : boxplot.Q3 = reader.ReadDouble(); + + var token = reader.GetCurrentJsonToken(); + if (token != JsonToken.EndObject) + { + reader.ReadNext(); // , + reader.ReadNext(); // "lower" + reader.ReadNext(); // : + boxplot.Lower = reader.ReadDouble(); + reader.ReadNext(); // , + reader.ReadNext(); // "upper" + reader.ReadNext(); // : + boxplot.Upper = reader.ReadDouble(); + } + return boxplot; } diff --git a/src/Nest/Aggregations/Metric/Boxplot/BoxplotAggregate.cs b/src/Nest/Aggregations/Metric/Boxplot/BoxplotAggregate.cs index e8dcb8c4ebb..97c96c7c009 100644 --- a/src/Nest/Aggregations/Metric/Boxplot/BoxplotAggregate.cs +++ b/src/Nest/Aggregations/Metric/Boxplot/BoxplotAggregate.cs @@ -15,5 +15,9 @@ public class BoxplotAggregate : MetricAggregateBase public double Q2 { get; set; } public double Q3 { get; set; } + + public double Lower { get; set; } + + public double Upper { get; set; } } } diff --git a/tests/Tests/Aggregations/Metric/Boxplot/BoxplotAggregationUsageTests.cs b/tests/Tests/Aggregations/Metric/Boxplot/BoxplotAggregationUsageTests.cs index e000b1f906e..5368ceef7db 100644 --- a/tests/Tests/Aggregations/Metric/Boxplot/BoxplotAggregationUsageTests.cs +++ b/tests/Tests/Aggregations/Metric/Boxplot/BoxplotAggregationUsageTests.cs @@ -77,6 +77,8 @@ protected override void ExpectResponse(ISearchResponse response) boxplot.Q1.Should().BeGreaterOrEqualTo(0); boxplot.Q2.Should().BeGreaterOrEqualTo(0); boxplot.Q3.Should().BeGreaterOrEqualTo(0); + boxplot.Lower.Should().BeGreaterOrEqualTo(0); + boxplot.Upper.Should().BeGreaterOrEqualTo(0); boxplot.Meta.Should().NotBeNull().And.HaveCount(1); boxplot.Meta["foo"].Should().Be("bar"); }