WARNING: Version 5.x has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Matrix Stats Aggregation Usage
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Matrix Stats Aggregation Usage
editFluent DSL example
edits => s .Aggregations(a => a .MatrixStats("matrixstats", ms => ms .Meta(m => m .Add("foo", "bar") ) .Fields(fs => fs .Field(p => p.NumberOfCommits) .Field(p => p.NumberOfContributors) ) .Missing(m => m .Add(Field<Project>(p => p.NumberOfCommits), 0) .Add(Field<Project>(p => p.NumberOfContributors), 1) ) .Mode(MatrixStatsMode.Median) ) )
Object Initializer syntax example
editnew SearchRequest<Project> { Aggregations = new MatrixStatsAggregation("matrixstats", Field<Project>(p => p.NumberOfCommits)) { Meta = new Dictionary<string, object> { { "foo", "bar" } }, Missing = new Dictionary<Field, double> { { "numberOfCommits", 0.0 }, { "numberOfContributors", 1.0 }, }, Mode = MatrixStatsMode.Median, Fields = Field<Project>(p => p.NumberOfCommits).And("numberOfContributors") } }
Example json output.
{ "aggs": { "matrixstats": { "meta": { "foo": "bar" }, "matrix_stats": { "fields": [ "numberOfCommits", "numberOfContributors" ], "missing": { "numberOfCommits": 0.0, "numberOfContributors": 1.0 }, "mode": "median" } } } }
Handling Responses
editresponse.ShouldBeValid(); var matrix = response.Aggs.MatrixStats("matrixstats"); matrix.Should().NotBeNull(); matrix.Fields.Should().NotBeNull().And.HaveCount(2); AssertField(matrix, "numberOfCommits"); AssertField(matrix, "numberOfContributors");