From f121e8309db5a169467177a5b6cc3ee9b78a719e Mon Sep 17 00:00:00 2001 From: Shani Elharrar Date: Thu, 3 Mar 2016 22:34:28 +0200 Subject: [PATCH] ElasticSearch Terms & Date Histogram: Support 'missing' setting --- .../datasource/elasticsearch/bucket_agg.js | 1 + .../elasticsearch/partials/bucket_agg.html | 36 +++++++++++++++---- .../datasource/elasticsearch/query_builder.js | 8 +++++ .../datasource/elasticsearch/query_def.js | 4 +-- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/bucket_agg.js b/public/app/plugins/datasource/elasticsearch/bucket_agg.js index 47d88a6ea3c..c397d7936a8 100644 --- a/public/app/plugins/datasource/elasticsearch/bucket_agg.js +++ b/public/app/plugins/datasource/elasticsearch/bucket_agg.js @@ -27,6 +27,7 @@ function (angular, _, queryDef) { $scope.orderByOptions = []; $scope.bucketAggTypes = queryDef.bucketAggTypes; + $scope.bucketAggTypesHash = _.indexBy(queryDef.bucketAggTypes, 'value'); $scope.orderOptions = queryDef.orderOptions; $scope.sizeOptions = queryDef.sizeOptions; diff --git a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html index 5c1b538cf9a..d222b55d856 100644 --- a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html +++ b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html @@ -57,7 +57,7 @@
-
+
  • Trim edges points @@ -71,11 +71,23 @@
+
+
    +
  • + Missing + The missing parameter defines how documents that are missing a value should be treated. By default they will be ignored but it is also possible to treat them as if they had a value +
  • +
  • + +
  • +
+
+
    -
  • +
  • Order
  • @@ -86,7 +98,7 @@
    -
  • +
  • Size
  • @@ -95,9 +107,9 @@
-
+
    -
  • +
  • Order By
  • @@ -106,6 +118,18 @@
+
+
    +
  • + Missing + The missing parameter defines how documents that are missing a value should be treated. By default they will be ignored but it is also possible to treat them as if they had a value +
  • +
  • + +
  • +
+
+
@@ -129,5 +153,3 @@
- - diff --git a/public/app/plugins/datasource/elasticsearch/query_builder.js b/public/app/plugins/datasource/elasticsearch/query_builder.js index dd071ba137d..d8c28ed1d82 100644 --- a/public/app/plugins/datasource/elasticsearch/query_builder.js +++ b/public/app/plugins/datasource/elasticsearch/query_builder.js @@ -48,6 +48,10 @@ function (queryDef) { } } + if (aggDef.settings.missing) { + queryNode.terms.missing = aggDef.settings.missing; + } + return queryNode; }; @@ -67,6 +71,10 @@ function (queryDef) { esAgg.format = "epoch_millis"; } + if (settings.missing) { + esAgg.missing = settings.missing; + } + return esAgg; }; diff --git a/public/app/plugins/datasource/elasticsearch/query_def.js b/public/app/plugins/datasource/elasticsearch/query_def.js index ae44af3e2db..7e76a13731a 100644 --- a/public/app/plugins/datasource/elasticsearch/query_def.js +++ b/public/app/plugins/datasource/elasticsearch/query_def.js @@ -20,9 +20,9 @@ function (_) { ], bucketAggTypes: [ - {text: "Terms", value: 'terms' }, + {text: "Terms", value: 'terms', supportsMissing: true }, {text: "Filters", value: 'filters' }, - {text: "Date Histogram", value: 'date_histogram' }, + {text: "Date Histogram", value: 'date_histogram', supportsMissing: true }, ], orderByOptions: [