mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* Fix filtering out global time range * Check if timefilter actually was created
This commit is contained in:
parent
165644ac32
commit
420a20e799
2 changed files with 13 additions and 24 deletions
|
@ -7,7 +7,15 @@ export function RootSearchSourceProvider(Private, $rootScope, timefilter) {
|
|||
globalSource.inherits(false); // this is the final source, it has no parents
|
||||
globalSource.filter(function (globalSource) {
|
||||
// dynamic time filter will be called in the _flatten phase of things
|
||||
return timefilter.get(globalSource.get('index'));
|
||||
const filter = timefilter.get(globalSource.get('index'));
|
||||
// Attach a meta property to it, that we check inside visualizations
|
||||
// to remove that timefilter again because we use our explicitly passed in one.
|
||||
// This should be removed as soon as we got rid of inheritance in SearchSource
|
||||
// across the boundary or visualization.
|
||||
if (filter) {
|
||||
filter.meta = { _globalTimefilter: true };
|
||||
}
|
||||
return filter;
|
||||
});
|
||||
|
||||
let appSource; // set in setAppSource()
|
||||
|
|
|
@ -9,32 +9,13 @@ const CourierRequestHandlerProvider = function (Private, courier, timefilter) {
|
|||
/**
|
||||
* TODO: This code can be removed as soon as we got rid of inheritance in the
|
||||
* searchsource and pass down every filter explicitly.
|
||||
* we're only adding one range filter against the timeFieldName to ensure
|
||||
* that our filter is the only one applied and override the global filters.
|
||||
* this does rely on the "implementation detail" that filters are added first
|
||||
* on the leaf SearchSource and subsequently on the parents.
|
||||
* We are filtering out the global timefilter by the meta key set by the root
|
||||
* search source on that filter.
|
||||
*/
|
||||
function removeSearchSourceParentTimefilter(searchSource) {
|
||||
searchSource.addFilterPredicate((filter, state) => {
|
||||
if (!filter.range) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const index = searchSource.index() || searchSource.getParent().index();
|
||||
const timeFieldName = index && index.timeFieldName;
|
||||
if (!index || !timeFieldName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Only check if we need to filter out this filter if it's actual a range filter
|
||||
// on our time field and not any other field.
|
||||
if (!filter.range[timeFieldName]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !(state.filters || []).find(f => f.range && f.range[timeFieldName]);
|
||||
searchSource.addFilterPredicate((filter) => {
|
||||
return !_.get(filter, 'meta._globalTimefilter', false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue