diff --git a/src/kibana/plugins/dashboard/index.js b/src/kibana/plugins/dashboard/index.js index 3ce27d9d39970..6f49ce50d7717 100644 --- a/src/kibana/plugins/dashboard/index.js +++ b/src/kibana/plugins/dashboard/index.js @@ -56,10 +56,20 @@ define(function (require) { var dash = $scope.dash = $route.current.locals.dash; $scope.$on('$destroy', dash.destroy); + var matchQueryFilter = function (filter) { + return filter.query && filter.query.query_string && !filter.meta; + }; + + var extractQueryFromFilters = function (filters) { + var filter = _.find(filters, matchQueryFilter); + if (filter) return filter.query; + }; + var stateDefaults = { title: dash.title, panels: dash.panelsJSON ? JSON.parse(dash.panelsJSON) : [], - query: {query_string: {query: '*'}} + query: extractQueryFromFilters(dash.searchSource.getOwn('filter')) || {query_string: {query: '*'}}, + filters: _.reject(dash.searchSource.getOwn('filter'), matchQueryFilter) }; var $state = $scope.state = new AppState(stateDefaults);