Skip to content

Commit

Permalink
Ensure the field exists in the index pattern before grabbing it (elas…
Browse files Browse the repository at this point in the history
  • Loading branch information
trevan authored and Aliaksandr Yankouski committed Jul 16, 2018
1 parent 75cee85 commit a28c684
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ui/public/filter_bar/lib/map_phrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down

0 comments on commit a28c684

Please sign in to comment.