Commit 41ea74f8 by Rashid Khan

Merge pull request #152 from nikicat/derivequeryfix

derivequery: pass search filter to query
parents d3b0a6a0 ac24a06d
<div> <div>
<div class="row-fluid"> <div class="row-fluid">
<div class="span12"> <div class="span12">
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. <strong>You should be careful not to select a high cardinality field</strong> 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. <strong>You should be careful not to select a high cardinality field</strong> as Elasticsearch must load all of these values into memory.<p>
Query Mode allows to optionally append original query to each term in the list.
</div> </div>
</div> </div>
<div class="row-fluid"> <div class="row-fluid">
<div class="span3"> <div class="span1">
<label class="small">Length</label> <label class="small">Length</label>
<input type="number" style="width:80%" ng-model="panel.size" ng-change="set_refresh(true)"> <input type="number" style="width:80%" ng-model="panel.size" ng-change="set_refresh(true)">
</div> </div>
<div class="span3">
<label class="small">Query Mode</label>
<select style="width:80%" ng-change="set_refresh(true)" ng-model='panel.mode' ng-options="f for f in ['terms only','AND', 'OR']"></select>
</div>
<div class="span8"> <div class="span8">
<label class="small">Exclude Terms(s) (comma seperated)</label> <label class="small">Exclude Terms(s) (comma seperated)</label>
<input array-join type="text" style="width:90%" ng-change="set_refresh(true)" ng-model='panel.exclude'></input> <input array-join type="text" style="width:90%" ng-change="set_refresh(true)" ng-model='panel.exclude'></input>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
* field :: the field to facet on * field :: the field to facet on
* size :: how many queries to generate * size :: how many queries to generate
* fields :: a list of fields known to us * fields :: a list of fields known to us
* query_mode :: how to create query
### Group Events ### Group Events
#### Sends #### Sends
...@@ -34,6 +35,7 @@ angular.module('kibana.derivequeries', []) ...@@ -34,6 +35,7 @@ angular.module('kibana.derivequeries', [])
fields : [], fields : [],
spyable : true, spyable : true,
size : 5, size : 5,
mode : 'terms only',
exclude : [] exclude : []
} }
_.defaults($scope.panel,_d); _.defaults($scope.panel,_d);
...@@ -81,8 +83,15 @@ angular.module('kibana.derivequeries', []) ...@@ -81,8 +83,15 @@ angular.module('kibana.derivequeries', [])
results.then(function(results) { results.then(function(results) {
$scope.panel.loading = false; $scope.panel.loading = false;
var data = []; 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) { _.each(results.facets.query.terms, function(v) {
data.push($scope.panel.field+':"'+v.term+'"') data.push($scope.panel.field+':"'+v.term+'"'+suffix)
}); });
$scope.send_query(data) $scope.send_query(data)
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment