Percentile Ranks aggregation

edit

A multi-value metrics aggregation that calculates one or more percentile ranks over numeric values extracted from the aggregated documents. These values can be extracted either from specific numeric fields in the documents, or be generated by a provided script.

Fluent DSL

edit
var result = client.Search<ElasticSearchProject>(s => s
    .Aggregations(a => a
        .PercentileRanks("commits_outlier", pr => pr
            .Field(p => p.NumberOfCommits)
            .Values(new[] { 15d, 30d })
            .Script("doc['numberOfCommits'].value * 1.2")
        )
    )
);

var percentilRanksAgg = r.Aggs.PercentilesRank("commits_outlier");
foreach (var item in percentilRanksAgg.Items)
{
    // do something with item
}

Object Initializer Syntax

edit
var request = new SearchRequest
{
    Aggregations = new Dictionary<string, IAggregationContainer>
    {
        { "commits_outlier", new AggregationContainer
            {
                PercentileRanks = new PercentileRanksAggregation
                {
                    Field = "name",
                    Values = new[] { 15d, 30d },
                    Script = "doc['numberOfCommits'].value * 1.2"
                }
            }
        }
    }
};

Refer to the original docs for more information.