Skip to content

Commit cd5d590

Browse files
Update BoxplotAggregate response (#5133) (#5138)
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. Co-authored-by: Steve Gordon <sgordon@hotmail.co.uk>
1 parent 20805d1 commit cd5d590

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/Nest/Aggregations/AggregateFormatter.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ private IAggregate GetBoxplotAggregate(ref JsonReader reader, IJsonFormatterReso
258258
reader.ReadNext(); // "q3"
259259
reader.ReadNext(); // :
260260
boxplot.Q3 = reader.ReadDouble();
261+
262+
var token = reader.GetCurrentJsonToken();
263+
if (token != JsonToken.EndObject)
264+
{
265+
reader.ReadNext(); // ,
266+
reader.ReadNext(); // "lower"
267+
reader.ReadNext(); // :
268+
boxplot.Lower = reader.ReadDouble();
269+
reader.ReadNext(); // ,
270+
reader.ReadNext(); // "upper"
271+
reader.ReadNext(); // :
272+
boxplot.Upper = reader.ReadDouble();
273+
}
274+
261275
return boxplot;
262276
}
263277

src/Nest/Aggregations/Metric/Boxplot/BoxplotAggregate.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ public class BoxplotAggregate : MetricAggregateBase
1515
public double Q2 { get; set; }
1616

1717
public double Q3 { get; set; }
18+
19+
public double Lower { get; set; }
20+
21+
public double Upper { get; set; }
1822
}
1923
}

tests/Tests/Aggregations/Metric/Boxplot/BoxplotAggregationUsageTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
7777
boxplot.Q1.Should().BeGreaterOrEqualTo(0);
7878
boxplot.Q2.Should().BeGreaterOrEqualTo(0);
7979
boxplot.Q3.Should().BeGreaterOrEqualTo(0);
80+
boxplot.Lower.Should().BeGreaterOrEqualTo(0);
81+
boxplot.Upper.Should().BeGreaterOrEqualTo(0);
8082
boxplot.Meta.Should().NotBeNull().And.HaveCount(1);
8183
boxplot.Meta["foo"].Should().Be("bar");
8284
}

0 commit comments

Comments
 (0)