Commit 5eb8c41a by Rashid Khan

Fixed NOT queries

parent 86408301
......@@ -127,13 +127,14 @@ function top_field_values(docs,field,count) {
}).reverse().slice(0,count)
}
function add_to_query(original,field,value) {
function add_to_query(original,field,value,negate) {
var not = negate ? "NOT " : "";
if(value !== '')
var query = field + ":" + "\"" + addslashes(value.toString()) + "\"";
else
var query = "_missing_:" + field;
var glue = original != "" ? " AND " : "";
return original + glue + query;
return original + glue + not + query;
}
/**
* Calculate a graph interval
......
......@@ -13,10 +13,10 @@
</thead>
<tbody>
<tr ng-repeat='field in micropanel.values'>
<td>{{field[0]}}</td>
<td>{{{true: "__blank__",false:field[0]}[field[0] == ""]}}</td>
<td>
<i class="pointer icon-search" ng-click="build_search(micropanel.field,field[0]);dismiss();"></i>
<i class="pointer icon-ban-circle" ng-click="build_search('NOT '+micropanel.field,field[0]);dismiss();"></i>
<i class="pointer icon-ban-circle" ng-click="build_search(micropanel.field,field[0],true);dismiss();"></i>
</td>
<td>{{field[1]}}</td>
</tr>
......
......@@ -58,8 +58,8 @@ angular.module('kibana.fields', [])
eventBus.broadcast($scope.$id,$scope.panel.group,"selected_fields",$scope.active)
}
$scope.build_search = function(field, value) {
$scope.panel.query = add_to_query($scope.panel.query,field,value)
$scope.build_search = function(field, value,negate) {
$scope.panel.query = add_to_query($scope.panel.query,field,value,negate)
eventBus.broadcast($scope.$id,$scope.panel.group,'query',$scope.panel.query);
}
......
......@@ -39,7 +39,7 @@
<td>{{key}}</td>
<td>
<i class='icon-search pointer' ng-click="build_search(key,value)"></i>
<i class='icon-ban-circle pointer' ng-click="build_search('NOT '+key,value)"></i>
<i class='icon-ban-circle pointer' ng-click="build_search(key,value,true)"></i>
</td>
<td>{{value}}</td>
</tr>
......
......@@ -67,8 +67,8 @@ angular.module('kibana.table', [])
$scope.get_data();
}
$scope.build_search = function(field, value) {
$scope.panel.query = add_to_query($scope.panel.query,field,value)
$scope.build_search = function(field, value,negate) {
$scope.panel.query = add_to_query($scope.panel.query,field,value,negate)
$scope.panel.offset = 0;
$scope.get_data();
eventBus.broadcast($scope.$id,$scope.panel.group,'query',$scope.panel.query);
......
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