From ffbe9578d5088493eba321910d4b60ea7c24973c Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Tue, 4 Jul 2023 10:19:30 +0200 Subject: [PATCH] [Discover] Refresh fields when entering Discover (#160195) - Closes https://github.com/elastic/kibana/issues/156556 - Probably also addresses https://github.com/elastic/kibana/issues/157239 ## Summary This PR allows to refresh fields list when revisiting Discover page. ## For testing 1. Open discover 2. In a separate tab open Dev Tools and create documents which include new field names 3. Press "Refresh" in the unified search bar on Discover and notice that new fields appear under Unmapped section 4. Navigate to another Kibana app (for example Home page) 5. Navigate back to Discover and notice that new fields are now under Available section and have a proper icon. (cherry picked from commit 4819efa8eb16529db807043d36a1214070e10c79) --- .../public/application/main/utils/resolve_data_view.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/discover/public/application/main/utils/resolve_data_view.ts b/src/plugins/discover/public/application/main/utils/resolve_data_view.ts index d846f7b949513..fc6a1ae9d166e 100644 --- a/src/plugins/discover/public/application/main/utils/resolve_data_view.ts +++ b/src/plugins/discover/public/application/main/utils/resolve_data_view.ts @@ -70,7 +70,7 @@ export async function loadDataView({ let fetchedDataView: DataView | null = null; // try to fetch adhoc data view first try { - fetchedDataView = fetchId ? await dataViews.get(fetchId, false) : null; + fetchedDataView = fetchId ? await dataViews.get(fetchId, false, true) : null; if (fetchedDataView && !fetchedDataView.isPersisted()) { return { list: dataViewList || [], @@ -88,7 +88,10 @@ export async function loadDataView({ let defaultDataView: DataView | null = null; if (!fetchedDataView) { try { - defaultDataView = await dataViews.getDefaultDataView({ displayErrors: false }); + defaultDataView = await dataViews.getDefaultDataView({ + displayErrors: false, + refreshFields: true, + }); } catch (e) { // }