diff --git a/panels/derivequeries/editor.html b/panels/derivequeries/editor.html index 442e55d72a8..56922bc2efa 100644 --- a/panels/derivequeries/editor.html +++ b/panels/derivequeries/editor.html @@ -1,17 +1,22 @@
- The derive queries panel takes a query and a field, then runs a terms facet against both and generates a list of terms to query on. For example, you might want to see a histogram of the top 5 requests that return a 404. You should be careful not to select a high cardinality field as Elasticsearch must load all of these values into memory. + The derive queries panel takes a query and a field, then runs a terms facet against both and generates a list of terms to query on. For example, you might want to see a histogram of the top 5 requests that return a 404. You should be careful not to select a high cardinality field as Elasticsearch must load all of these values into memory.

+ Query Mode allows to optionally append original query to each term in the list.

-
+
+
+ + +
- +
-
\ No newline at end of file +
diff --git a/panels/derivequeries/module.js b/panels/derivequeries/module.js index 09f0233d47b..e62d065439d 100644 --- a/panels/derivequeries/module.js +++ b/panels/derivequeries/module.js @@ -10,6 +10,7 @@ * field :: the field to facet on * size :: how many queries to generate * fields :: a list of fields known to us + * query_mode :: how to create query ### Group Events #### Sends @@ -33,6 +34,7 @@ angular.module('kibana.derivequeries', []) fields : [], spyable : true, size : 5, + mode : 'terms only', exclude : [] } _.defaults($scope.panel,_d); @@ -80,8 +82,15 @@ angular.module('kibana.derivequeries', []) results.then(function(results) { $scope.panel.loading = false; var data = []; + if ($scope.panel.query === '' || $scope.panel.mode === 'terms only') { + var suffix = ''; + } else if ($scope.panel.mode === 'AND') { + var suffix = ' AND ' + $scope.panel.query; + } else if ($scope.panel.mode === 'OR') { + var suffix = ' OR ' + $scope.panel.query; + } _.each(results.facets.query.terms, function(v) { - data.push($scope.panel.field+':"'+v.term+'" AND ' + ($scope.panel.query || '*')) + data.push($scope.panel.field+':"'+v.term+'"'+suffix) }); $scope.send_query(data) });