From cf6a769f1eed1ce4cfd0ce08367bc5d5da0138d7 Mon Sep 17 00:00:00 2001 From: Trevan Richins Date: Tue, 10 Jul 2018 13:59:29 -0600 Subject: [PATCH] Ensure the field exists in the index pattern before grabbing it --- src/ui/public/filter_bar/lib/map_phrase.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ui/public/filter_bar/lib/map_phrase.js b/src/ui/public/filter_bar/lib/map_phrase.js index 75e4a9224ffa8..25018d4746e2b 100644 --- a/src/ui/public/filter_bar/lib/map_phrase.js +++ b/src/ui/public/filter_bar/lib/map_phrase.js @@ -33,11 +33,11 @@ export function FilterBarLibMapPhraseProvider(Promise, indexPatterns) { const params = isScriptedPhraseFilter ? filter.script.script.params : filter.query.match[key]; const query = isScriptedPhraseFilter ? params.value : params.query; - // Sometimes a filter will end up with an invalid index param. This could happen for a lot of reasons, + // Sometimes a filter will end up with an invalid index or field param. This could happen for a lot of reasons, // for example a user might manually edit the url or the index pattern's ID might change due to // external factors e.g. a reindex. We only need the index in order to grab the field formatter, so we fallback - // on displaying the raw value if the index is invalid. - const value = indexPattern ? indexPattern.fields.byName[key].format.convert(query) : query; + // on displaying the raw value if the index or field is invalid. + const value = (indexPattern && indexPattern.fields.byName[key]) ? indexPattern.fields.byName[key].format.convert(query) : query; return { type, key, value, params }; }