Skip to content

Percentiles Bucket Aggregation relies on ordered percents array #24331

@cbuescher

Description

@cbuescher

An interesting edge case that I found when working on #24330: It seems that percentiles_bucket relies on the percents parameter beeing specifies in increasing order or magnitude. If the list of percentiles to calculate is provided in a different order, e.g.

"percentiles_monthly_sales": {
            "percentiles_bucket": {
                "buckets_path": "sales_per_month>sales", 
                "percents": [ 50.0, 25.0, 75.0 ] 
            }
        }

the following error is thrown:

"type": "illegal_argument_exception",
    "reason": "Percent requested [50.0] was not one of the computed percentiles.  Available keys are: [50.0, 25.0, 75.0]"

The reason seems to be that in InternalPercentileBucket#percentile(double percent) (

) the internal array is assumed to be sorted, but we don't enforce this, e.g. in the PercentilesBucketPipelineAggregator or even before when parsing the request.

I think we could either throw an error early if we think the percents need to be provided in order, re-sort the array if the user provided it unsorted or change the implementation of InternalPercentileBucket so it doesn't rely on an ordered array.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions