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.
Percentiles Aggregation Usage
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Percentiles Aggregation Usage
editFluent DSL example
edits => s .Aggregations(a => a .Percentiles("commits_outlier", pr => pr .Field(p => p.NumberOfCommits) .Percents(95, 99, 99.9) .Method(m => m .HDRHistogram(hdr => hdr .NumberOfSignificantValueDigits(3) ) ) .Script("doc['numberOfCommits'].value * 1.2") .Missing(0) ) )
Object Initializer syntax example
editnew SearchRequest<Project> { Aggregations = new PercentilesAggregation("commits_outlier", Field<Project>(p => p.NumberOfCommits)) { Percents = new[] { 95, 99, 99.9 }, Method = new HDRHistogramMethod { NumberOfSignificantValueDigits = 3 }, Script = new InlineScript("doc['numberOfCommits'].value * 1.2"), Missing = 0 } }
Example json output.
{ "aggs": { "commits_outlier": { "percentiles": { "field": "numberOfCommits", "percents": [ 95.0, 99.0, 99.9 ], "hdr": { "number_of_significant_value_digits": 3 }, "script": { "inline": "doc['numberOfCommits'].value * 1.2" }, "missing": 0.0 } } } }
Handling Responses
editresponse.ShouldBeValid(); var commitsOutlier = response.Aggs.Percentiles("commits_outlier"); commitsOutlier.Should().NotBeNull(); commitsOutlier.Items.Should().NotBeNullOrEmpty(); foreach (var item in commitsOutlier.Items) item.Value.Should().BeGreaterThan(0);
Was this helpful?
Thank you for your feedback.