A newer version is available. For the latest information, see the
current release documentation.
Average Aggregation Usage
editAverage Aggregation Usage
editFluent DSL example
edita => a .Average("average_commits", avg => avg .Meta(m => m .Add("foo", "bar") ) .Field(p => p.NumberOfCommits) .Missing(10) .Script(ss => ss.Source("_value * 1.2")) )
Object Initializer syntax example
editnew AverageAggregation("average_commits", Field<Project>(p => p.NumberOfCommits)) { Meta = new Dictionary<string, object> { { "foo", "bar" } }, Missing = 10, Script = new InlineScript("_value * 1.2") }
Example json output.
{ "average_commits": { "meta": { "foo": "bar" }, "avg": { "field": "numberOfCommits", "missing": 10.0, "script": { "source": "_value * 1.2" } } } }
Handling Responses
editresponse.ShouldBeValid(); var commitsAvg = response.Aggregations.Average("average_commits"); commitsAvg.Should().NotBeNull(); commitsAvg.Value.Should().BeGreaterThan(0); commitsAvg.Meta.Should().NotBeNull().And.HaveCount(1); commitsAvg.Meta["foo"].Should().Be("bar");