From 867bfbeddbe50e1d560f469576c0905ee137eb06 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Tue, 22 Oct 2013 15:29:14 -0700 Subject: [PATCH] Implemented topN query type, refactored querySrv --- src/app/panels/query/editors/lucene.html | 0 src/app/panels/query/editors/regex.html | 0 src/app/panels/query/editors/topN.html | 12 ++++++ src/app/panels/query/help/lucene.html | 30 +++++++++++++++ src/app/panels/query/help/regex.html | 10 +++++ src/app/panels/query/help/topN.html | 14 +++++++ src/app/panels/query/helpModal.html | 12 ++++++ src/app/panels/query/meta.html | 44 +++++++++++++--------- src/app/panels/query/module.js | 48 +++++++++++++++++++++++- src/app/panels/query/query.css | 3 ++ 10 files changed, 154 insertions(+), 19 deletions(-) create mode 100644 src/app/panels/query/editors/lucene.html create mode 100644 src/app/panels/query/editors/regex.html create mode 100644 src/app/panels/query/editors/topN.html create mode 100644 src/app/panels/query/help/lucene.html create mode 100644 src/app/panels/query/help/regex.html create mode 100644 src/app/panels/query/help/topN.html create mode 100644 src/app/panels/query/helpModal.html diff --git a/src/app/panels/query/editors/lucene.html b/src/app/panels/query/editors/lucene.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/panels/query/editors/regex.html b/src/app/panels/query/editors/regex.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/panels/query/editors/topN.html b/src/app/panels/query/editors/topN.html new file mode 100644 index 00000000000..71496541906 --- /dev/null +++ b/src/app/panels/query/editors/topN.html @@ -0,0 +1,12 @@ +
+
+ +

+
+ +

+
+ +

diff --git a/src/app/panels/query/help/lucene.html b/src/app/panels/query/help/lucene.html new file mode 100644 index 00000000000..9e860e97d47 --- /dev/null +++ b/src/app/panels/query/help/lucene.html @@ -0,0 +1,30 @@ +The lucene query type uses LUCENE query string syntax to find matching documents or events within Elasticsearch. + +

Examples

+ + +

Wildcard searches can be run on individual terms, using ? to replace +a single character, and * to replace zero or more characters:

+
qu?ck bro*
+ + diff --git a/src/app/panels/query/help/regex.html b/src/app/panels/query/help/regex.html new file mode 100644 index 00000000000..8e38ab96fe2 --- /dev/null +++ b/src/app/panels/query/help/regex.html @@ -0,0 +1,10 @@ +The regex query allows you to use regular expressions to match terms in the _all field. + +A detailed overview of lucene's regex engine is available here: Regular expressions in Elasticsearch + +
A note on anchoring
+Lucene’s patterns are always anchored. The pattern provided must match the entire string. For string "abcde": +

+ab.* will match
+abcd will not match
+ diff --git a/src/app/panels/query/help/topN.html b/src/app/panels/query/help/topN.html new file mode 100644 index 00000000000..9fc7c3aa8e0 --- /dev/null +++ b/src/app/panels/query/help/topN.html @@ -0,0 +1,14 @@ +The topN query uses an Elasticsearch terms facet to find the most common terms in a field and build queries from the result. The topN query uses LUCENE query string syntax + +

Parameters

+ \ No newline at end of file diff --git a/src/app/panels/query/helpModal.html b/src/app/panels/query/helpModal.html new file mode 100644 index 00000000000..3cbbf8cdf7a --- /dev/null +++ b/src/app/panels/query/helpModal.html @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/src/app/panels/query/meta.html b/src/app/panels/query/meta.html index 2208455fbad..3113f7f0e8e 100755 --- a/src/app/panels/query/meta.html +++ b/src/app/panels/query/meta.html @@ -1,26 +1,34 @@ -
+
-
- -
- -
-
- + +
+   About the {{querySrv.list[id].type}} query + +
+ + + +
+ +
+ + +
+
+ +
+
- - + + Pin +
\ No newline at end of file diff --git a/src/app/panels/query/module.js b/src/app/panels/query/module.js index a7a4c6906b4..7d31b1a6b5c 100755 --- a/src/app/panels/query/module.js +++ b/src/app/panels/query/module.js @@ -19,7 +19,7 @@ define([ var module = angular.module('kibana.panels.query', []); app.useModule(module); - module.controller('query', function($scope, querySrv, $rootScope, dashboard) { + module.controller('query', function($scope, querySrv, $rootScope, dashboard, $q, $modal) { $scope.panelMeta = { status : "Stable", description : "Manage all of the queries on the dashboard. You almost certainly need one of "+ @@ -45,6 +45,13 @@ define([ }; }); + var queryHelpModal = $modal({ + template: './app/panels/query/helpModal.html', + persist: true, + show: false, + scope: $scope, + }); + $scope.init = function() { }; @@ -65,6 +72,34 @@ define([ return querySrv.queryTypes[type].icon; }; + $scope.queryConfig = function(type) { + return "./app/panels/query/editors/"+(type||'lucene')+".html"; + }; + + $scope.queryHelpPath = function(type) { + return "./app/panels/query/help/"+(type||'lucene')+".html"; + }; + + $scope.queryHelp = function(type) { + $scope.help = { + type: type + }; + $q.when(queryHelpModal).then(function(modalEl) { + modalEl.modal('show'); + }); + }; + + $scope.typeChange = function(q) { + var _nq = { + id : q.id, + type : q.type, + query: q.query, + alias: q.alias, + color: q.color + }; + querySrv.list[_nq.id] = querySrv.defaults(_nq); + }; + var update_history = function(query) { if($scope.panel.remember > 0) { $scope.panel.history = _.union(query.reverse(),$scope.panel.history); @@ -78,4 +113,15 @@ define([ $scope.init(); }); + + module.directive('queryConfig', function() { + return { + restrict: 'A', + template: '
', + link: function(scope, elem) { + console.log(elem); + } + }; + }); + }); \ No newline at end of file diff --git a/src/app/panels/query/query.css b/src/app/panels/query/query.css index 7f3182823e1..44cedefe33c 100755 --- a/src/app/panels/query/query.css +++ b/src/app/panels/query/query.css @@ -2,6 +2,9 @@ display:inline-block; margin-right: 10px; } +.short-query input.search-query { + width: 280px; +} .begin-query { position:absolute; left:13px;