Commit cb8f020a by spenceralger

Merge pull request #431 from spenceralger/geo_point_filter

Fixes filtering on array values from the micro-analysis pop-out
parents 77e1e004 b160700e
...@@ -73,10 +73,20 @@ ...@@ -73,10 +73,20 @@
}; };
kbn.top_field_values = function(docs,field,count) { kbn.top_field_values = function(docs,field,count) {
var counts = _.countBy(_.pluck(docs,field),function(field){ var all_values = _.pluck(docs,field),
return _.isUndefined(field) ? '' : field; groups = {};
// manually grouping into pairs allows us to keep the original value,
_.each(all_values, function (value) {
var key = _.isUndefined(value) ? '' : value.toString();
if (_.has(groups, key)) {
groups[key][1] ++;
} else {
groups[key] = [value, 1];
}
}); });
return _.pairs(counts).sort(function(a, b) {
return _.values(groups).sort(function(a, b) {
return a[1] - b[1]; return a[1] - b[1];
}).reverse().slice(0,count); }).reverse().slice(0,count);
}; };
......
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