Skip to content

Commit

Permalink
Add ignore_unmapped to geo filters to prevent exception (#11461)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed May 10, 2017
1 parent 72dd928 commit 72443cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
33 changes: 25 additions & 8 deletions src/ui/public/filter_bar/lib/__tests__/map_geo_bounding_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ describe('Filter Bar Directive', function () {
},
geo_bounding_box: {
point: { // field name
top_left: {
lat: 5,
lon: 10
},
bottom_right: {
lat: 15,
lon: 20
}
top_left: { lat: 5, lon: 10 },
bottom_right: { lat: 15, lon: 20 }
}
}
};
Expand All @@ -57,5 +51,28 @@ describe('Filter Bar Directive', function () {
$rootScope.$apply();
});

it('should return the key and value even when using ignore_unmapped', function (done) {
const filter = {
meta: {
index: 'logstash-*'
},
geo_bounding_box: {
ignore_unmapped: true,
point: { // field name
top_left: { lat: 5, lon: 10 },
bottom_right: { lat: 15, lon: 20 }
}
}
};
mapGeoBoundingBox(filter).then(function (result) {
expect(result).to.have.property('key', 'point');
expect(result).to.have.property('value');
// remove html entities and non-alphanumerics to get the gist of the value
expect(result.value.replace(/&[a-z]+?;/g, '').replace(/[^a-z0-9]/g, '')).to.be('lat5lon10tolat15lon20');
done();
});
$rootScope.$apply();
});

});
});
3 changes: 2 additions & 1 deletion src/ui/public/filter_bar/lib/map_geo_bounding_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default function mapGeoBoundBoxProvider(Promise, courier) {
return courier
.indexPatterns
.get(filter.meta.index).then(function (indexPattern) {
key = _.keys(filter.geo_bounding_box)[0];
key = _.keys(filter.geo_bounding_box)
.filter(key => key !== 'ignore_unmapped')[0];
field = indexPattern.fields.byName[key];
topLeft = field.format.convert(filter.geo_bounding_box[field.name].top_left);
bottomRight = field.format.convert(filter.geo_bounding_box[field.name].bottom_right);
Expand Down
4 changes: 1 addition & 3 deletions src/ui/public/vis_maps/maps_renderbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
const indexPatternName = agg.vis.indexPattern.id;
const field = agg.fieldName();
const filter = {};
filter[filterName] = {};
filter[filterName] = { ignore_unmapped: true };
filter[filterName][field] = filterData;

const putFilter = Private(FilterBarPushFilterProvider)(getAppState());
Expand All @@ -237,5 +237,3 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin

return MapsRenderbot;
};


0 comments on commit 72443cd

Please sign in to comment.