Average Aggregation Usageedit

a => 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"))
)
new 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 Responsesedit

response.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");