From d55cc4e2a3c26d823611d06c25c20b0a6eead68c Mon Sep 17 00:00:00 2001 From: Dhia MOAKHAR Date: Sat, 3 Jun 2017 02:50:10 +0000 Subject: [PATCH] [elasticsearch] Fix add metric that was not working properly when selecting Raw Documet metric type, the $scope.target.metrics was replaced by [$scope.agg], however the pointer to this variables is shared with metricAggs. Instead we free the array and add $scope.agg --- public/app/plugins/datasource/elasticsearch/metric_agg.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/metric_agg.js b/public/app/plugins/datasource/elasticsearch/metric_agg.js index 90c303a5722..88053b0efac 100644 --- a/public/app/plugins/datasource/elasticsearch/metric_agg.js +++ b/public/app/plugins/datasource/elasticsearch/metric_agg.js @@ -67,7 +67,6 @@ function (angular, _, queryDef) { } else if (!$scope.agg.field) { $scope.agg.field = 'select field'; } - switch($scope.agg.type) { case 'cardinality': { var precision_threshold = $scope.agg.settings.precision_threshold || ''; @@ -105,12 +104,12 @@ function (angular, _, queryDef) { case 'raw_document': { $scope.agg.settings.size = $scope.agg.settings.size || 500; $scope.settingsLinkText = 'Size: ' + $scope.agg.settings.size ; - $scope.target.metrics = [$scope.agg]; + $scope.target.metrics.splice(0,$scope.target.metrics.length, $scope.agg); + $scope.target.bucketAggs = []; break; } } - if ($scope.aggDef.supportsInlineScript) { // I know this stores the inline script twice // but having it like this simplifes the query_builder