diff --git a/src/app/panels/query/editors/topN.html b/src/app/panels/query/editors/topN.html index 71496541906cd..8d2d2c322c794 100644 --- a/src/app/panels/query/editors/topN.html +++ b/src/app/panels/query/editors/topN.html @@ -1,12 +1,20 @@
-
-

-
- +
+

-
- +
+ +

+

+
+ +

+

+ +

diff --git a/src/app/services/querySrv.js b/src/app/services/querySrv.js index 11694ae77d31e..5aef91f0f2d01 100644 --- a/src/app/services/querySrv.js +++ b/src/app/services/querySrv.js @@ -56,7 +56,8 @@ function (angular, _, config, kbn) { query: "*", field: "_type", size: 5, - union: 'AND' + union: 'AND', + other: false } }; @@ -108,18 +109,35 @@ function (angular, _, config, kbn) { var results = request.doSearch(); // Like the regex and lucene queries, this returns a promise return results.then(function(data) { - var _colors = kbn.colorSteps(q.color,data.facets.query.terms.length); + var _colors = kbn.colorSteps(q.color,data.facets.query.terms.length+1); var i = -1; - return _.map(data.facets.query.terms,function(t) { + var terms = _.map(data.facets.query.terms,function(t) { + return t.term; + }); + + var queries = _.map(terms,function(term) { ++i; return self.defaults({ - query : q.field+':"'+kbn.addslashes(t.term)+'"'+suffix, - alias : t.term + (q.alias ? " ("+q.alias+")" : ""), + query : q.field+':"'+kbn.addslashes(term)+'"'+suffix, + alias : term + (q.alias ? " ("+q.alias+")" : ""), type : 'lucene', color : _colors[i], parent : q.id }); }); + + if (q.other) { + ++i; + queries.push(self.defaults({ + query : q.field+':(NOT ("'+terms.map(kbn.addslashes).join('" OR "')+'"))'+suffix, + alias : 'other' + (q.alias ? " ("+q.alias+")" : ""), + type : 'lucene', + color : _colors[i], + parent : q.id + })); + } + + return queries; }); } }