diff --git a/public/app/plugins/datasource/elasticsearch/bucket_agg.js b/public/app/plugins/datasource/elasticsearch/bucket_agg.js
index 43ef4f91ab7..1100f642d50 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 3790d18857e..e3e6cd6f5ff 100644
--- a/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html
+++ b/public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html
@@ -57,16 +57,23 @@