From 715a7caed157971c29af123b2c5040ee795e8f28 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Wed, 28 Jul 2021 11:42:57 +0300 Subject: [PATCH] [TSVB] Fixes bug with tophit aggregation and index not exist (#106814) * [TSVB] Fixes bug with tophit aggregation and no fields index * Update src/plugins/vis_type_timeseries/public/application/components/aggs/top_hit.js Co-authored-by: Alexey Antonov * Apply review comments Co-authored-by: Alexey Antonov --- .../public/application/components/aggs/top_hit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timeseries/public/application/components/aggs/top_hit.js b/src/plugins/vis_type_timeseries/public/application/components/aggs/top_hit.js index b9ef2d8913574..ade64fc3db8c5 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/aggs/top_hit.js +++ b/src/plugins/vis_type_timeseries/public/application/components/aggs/top_hit.js @@ -120,7 +120,7 @@ const TopHitAggUi = (props) => { const handleSelectChange = createSelectHandler(handleChange); const handleTextChange = createTextHandler(handleChange); const fieldsSelector = getIndexPatternKey(indexPattern); - const field = fields[fieldsSelector].find((f) => f.name === model.field); + const field = fields?.[fieldsSelector]?.find((f) => f.name === model.field); const aggWithOptions = getAggWithOptions(field, aggWithOptionsRestrictFields); const orderOptions = getOrderOptions();