Skip to content

Commit

Permalink
Generate key for ip range from/to agg
Browse files Browse the repository at this point in the history
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: elastic#8736
  • Loading branch information
Bargs authored and nreese committed Nov 10, 2016
1 parent bf40cf7 commit d77aad4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ui/public/agg_types/buckets/ip_range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
},
Expand Down

0 comments on commit d77aad4

Please sign in to comment.