Commit 5eb8c41a by Rashid Khan

Fixed NOT queries

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