Description
openedon Apr 3, 2017
Reported via Discuss forum: https://discuss.elastic.co/t/bucket-selector-aggregation-on-date-histogram--key/80986
The bucket_script
and bucket_selector
aggregations use the BucketHelpers.resolveBucketValue()
method to get the bucket_path
values from the buckets. That method requires that the return value is a Double
so currently it is required that all the bucket_path
s are numeric values. This presents a problem when trying to use the _key
of a bucket since the key might be a DateTime (in the case of a date_histogram
or date_range
aggs) or a String (in the case of a terms
agg).
One thing to note here is that all current pipeline aggs except the bucket_script
and bucket_selector
require the value from the bucket_path
to be a double, so whatever the solution to this bug we should maintain a route that guarantees a double to be returned.
I have a few thoughts on how to solve this but I don't know if which (if any) of them are a good idea yet:
- Change
BucketHelpers.resolveBucketValue()
to have a generic return type and somehow check that type is compatible before returning (not sure if this is possible since generics are not available at runtime) - Add a
public Object resolveBucketObject()
method inBucketHelpers
that just returns the value it gets from the bucket as long as its not an instance ofInternalAggregation
(So that its an actual value rather than an aggregation - Let the
bucket_script
andbucket_selector
aggs get the bucket path values directly usingBucket.getProperty()