From b2e1ecf7437534b4006726f0fc69cd17b59d12f8 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 546c09cdf34fd..6597ffdc14eae 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 @@ -117,7 +117,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();