Commit 9c7cd280 by Rashid Khan

added detection of empty fields

parent 48ad884e
...@@ -134,7 +134,7 @@ function get_field_value(object,field,opt) { ...@@ -134,7 +134,7 @@ function get_field_value(object,field,opt) {
function get_all_values_for_field(docs,field) { function get_all_values_for_field(docs,field) {
var field_array = []; var field_array = [];
_.each(docs, function(doc,k) { _.each(docs, function(doc,k) {
var value = doc[field] var value = doc[field] || ""
if(typeof value === 'object' && value != null) { if(typeof value === 'object' && value != null) {
field_array.push.apply(field_array,value); field_array.push.apply(field_array,value);
} else { } else {
...@@ -149,6 +149,14 @@ function top_field_values(docs,field,count) { ...@@ -149,6 +149,14 @@ function top_field_values(docs,field,count) {
return _.pairs(counts).sort(function(a, b) {return a[1] - b[1]}).reverse().slice(0,count) return _.pairs(counts).sort(function(a, b) {return a[1] - b[1]}).reverse().slice(0,count)
} }
function add_to_query(original,field,value) {
if(value !== '')
var query = field + ":" + "\"" + addslashes(value.toString()) + "\"";
else
var query = "_missing_:" + field;
var glue = original != "" ? " AND " : "";
return original + glue + query;
}
/** /**
* Calculate a graph interval * Calculate a graph interval
* *
......
...@@ -24,7 +24,6 @@ angular.module('kibana.fields', []) ...@@ -24,7 +24,6 @@ angular.module('kibana.fields', [])
} }
$scope.toggle_micropanel = function(field) { $scope.toggle_micropanel = function(field) {
//console.log(top_field_values($scope.docs,field,10))
$scope.micropanel = { $scope.micropanel = {
field: field, field: field,
values : top_field_values($scope.docs,field,10) values : top_field_values($scope.docs,field,10)
...@@ -45,9 +44,7 @@ angular.module('kibana.fields', []) ...@@ -45,9 +44,7 @@ angular.module('kibana.fields', [])
} }
$scope.build_search = function(field, value) { $scope.build_search = function(field, value) {
var query = field + ":" + "\"" + addslashes(value.toString()) + "\""; $scope.panel.query = add_to_query($scope.panel.query,field,value)
var glue = $scope.panel.query != "" ? " AND " : "";
$scope.panel.query = $scope.panel.query + glue + query;
eventBus.broadcast($scope.$id,$scope.panel.group,'query',$scope.panel.query); eventBus.broadcast($scope.$id,$scope.panel.group,'query',$scope.panel.query);
} }
......
...@@ -68,9 +68,7 @@ angular.module('kibana.table', []) ...@@ -68,9 +68,7 @@ angular.module('kibana.table', [])
} }
$scope.build_search = function(field, value) { $scope.build_search = function(field, value) {
var query = field + ":" + "\"" + addslashes(value.toString()) + "\""; $scope.panel.query = add_to_query($scope.panel.query,field,value)
var glue = $scope.panel.query != "" ? " AND " : "";
$scope.panel.query = $scope.panel.query + glue + query;
$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);
......
{
"title":"Monkey Showdown",
"rows":{
"row2":{
"height":"270px",
"panels":{
"Hamlet vs macbeth":{
"type":"stackedquery",
"span":8,
"queries":[
"play_name:Hamlet",
"play_name:macbeth"
],
"show": [ "lines", "fill" ]
},
"Hamlet vs Macbeth":{
"type":"piequery",
"span":4,
"donut":true,
"queries":[
"play_name:Hamlet",
"play_name:macbeth"
],
"colors":[
"#B07737",
"#85004B",
"#7BA4AF"
],
"field":"@message"
}
}
},
"row3":{
"height":"130px",
"panels":{
"Hamlet's Lines":{
"type":"histogram",
"span":8,
"show":[
"bars"
],
"label":"lines",
"query":"speaker:HAMLET",
"color":"#4A8737"
},
"Speakers":{
"type":"pieterms",
"donut":false,
"tilt":false,
"legend":true,
"field":"speaker",
"span":4,
"size":6,
"query":"play_name:Hamlet OR play_name:macbeth"
}
}
}
}
}
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