From 56a0b905593be551223359e8649e5d8a5a762fac Mon Sep 17 00:00:00 2001 From: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com> Date: Fri, 10 Jul 2020 17:04:05 +0200 Subject: [PATCH] Elastic: Fix error "e.buckets[Symbol.iterator] is not a function" when using filter (#26217) * Add bucket to array if it is not in array * Fix issue one level above * Rename variable * Move array check to processAggregationDocs (cherry picked from commit 6d8545da63f05498fb62904e430e38cb9fe38c00) --- .../app/plugins/datasource/elasticsearch/elastic_response.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/elasticsearch/elastic_response.ts b/public/app/plugins/datasource/elasticsearch/elastic_response.ts index 11b78c523db..2643afed23b 100644 --- a/public/app/plugins/datasource/elasticsearch/elastic_response.ts +++ b/public/app/plugins/datasource/elasticsearch/elastic_response.ts @@ -134,8 +134,8 @@ export class ElasticResponse { table.addColumn({ text: metricName }); values.push(value); }; - - for (const bucket of esAgg.buckets) { + const buckets = _.isArray(esAgg.buckets) ? esAgg.buckets : [esAgg.buckets]; + for (const bucket of buckets) { const values = []; for (const propValues of _.values(props)) {