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 @@
-
+
+
+ +
+
-
+
    -
  • +
  • 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: [