Stop sending null in ip range from/to props

The IP range agg supports open ended ranges. Elasticsearch 2.x was
lenient and accepted null as a value for the from/to props, but the
correct way to do an open ended range was always to omit the from/to
key entirely. ES 5.0 appears to be more strict and barfs when null is
passed. This commit removes the null values.

Fixes https://github.com/elastic/kibana/issues/8741
This commit is contained in:
Matthew Bargar 2016-10-18 19:18:14 -04:00
parent f344a4b262
commit 3ca45ba546

View file

@ -45,8 +45,16 @@ export default function RangeAggDefinition(Private) {
},
editor: ipRangesTemplate,
write: function (aggConfig, output) {
let ipRangeType = aggConfig.params.ipRangeType;
output.params.ranges = aggConfig.params.ranges[ipRangeType];
const ipRangeType = aggConfig.params.ipRangeType;
let ranges = aggConfig.params.ranges[ipRangeType];
if (ipRangeType === 'fromTo') {
ranges = _.map(ranges, (range) => {
return _.omit(range, _.isNull);
});
}
output.params.ranges = ranges;
}
}
]