Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignore_unmapped to geo filters to prevent exceptions #11461

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -11,7 +11,8 @@ export function FilterBarLibMapGeoBoundingBoxProvider(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;
};