Boxplot Aggregation Usage

edit

A boxplot metrics aggregation that computes boxplot of numeric values extracted from the aggregated documents. These values can be generated by a provided script or extracted from specific numeric or histogram fields in the documents.

boxplot aggregation returns essential information for making a box plot: minimum, maximum median, first quartile (25th percentile) and third quartile (75th percentile) values.

Be sure to read the Elasticsearch documentation on Boxplot Aggregation

Fluent DSL example

edit
a => a
.Boxplot("boxplot_commits", plot => plot
    .Meta(m => m
        .Add("foo", "bar")
    )
    .Field(p => p.NumberOfCommits)
    .Missing(10)
    .Compression(100)
)

Object Initializer syntax example

edit
new BoxplotAggregation("boxplot_commits", Field<Project>(p => p.NumberOfCommits))
{
    Meta = new Dictionary<string, object>
    {
        { "foo", "bar" }
    },
    Missing = 10,
    Compression = 100
}

Example json output.

{
  "boxplot_commits": {
    "meta": {
      "foo": "bar"
    },
    "boxplot": {
      "field": "numberOfCommits",
      "missing": 10.0,
      "compression": 100.0
    }
  }
}

Handling Responses

edit
response.ShouldBeValid();
var boxplot = response.Aggregations.Boxplot("boxplot_commits");
boxplot.Should().NotBeNull();
boxplot.Min.Should().BeGreaterOrEqualTo(0);
boxplot.Max.Should().BeGreaterOrEqualTo(0);
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");