elasticsearch/elasticsearch-net — pull request #1135 by gmarz (2014-12-12 05:22:07+00:00)
Title: Scripted metric aggregation support

Adding support for the [scripted metric aggeragtion](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html#search-aggregations-metrics-scripted-metric-aggregation)

The tricky bit with mapping this aggregation is that the resulting value that the scripts return can be of different types and our current `ValueMatric` only supports the value being numeric (implemented as a `double?`).

As a solution, I came up with `ScriptedValueMetric` which holds the original object deserialized by Json.Net, and exposes `ValueAs` which converts the value to the specified `T`. See these [tests](https://github.com/elasticsearch/elasticsearch-net/blob/feature/aggs-scriptedmetric/src/Tests/Nest.Tests.Integration/Aggregations/MetricAggregationTests.cs#L211). Open to suggestions on a better way to handle this...