Generate key for ip range from/to agg

Elasticsearch 5.0 no longer returns a `key` prop with ip range buckets
when from/to is used in the request. Looking at the [2.x docs][1] it
appears to be a mistake that it was ever included in the first place.
So now we'll generate the key ourselves.

[1]: https://www.elastic.co/guide/en/elasticsearch/reference/2.4/search-aggregations-bucket-iprange-aggregation.html

Fixes: https://github.com/elastic/kibana/issues/8736
This commit is contained in:
Matthew Bargar 2016-10-18 18:51:56 -04:00
parent e9363d21d0
commit f344a4b262

View file

@ -13,6 +13,13 @@ export default function RangeAggDefinition(Private) {
name: 'ip_range',
title: 'IPv4 Range',
createFilter: createFilter,
getKey: function (bucket, key, agg) {
if (key) return key;
const from = _.get(bucket, 'from', '*');
const to = _.get(bucket, 'to', '*');
return `${from}-${to}`;
},
makeLabel: function (aggConfig) {
return aggConfig.getFieldDisplayName() + ' IP ranges';
},