Skip to content

Commit

Permalink
Fix refresh on index (#8121) (#8123)
Browse files Browse the repository at this point in the history
(cherry picked from commit 1d36fd3)

Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 7dd5203 commit 5fa8614
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@ export const useIndexPattern = (services: DiscoverViewServices) => {
let isMounted = true;

const handleIndexPattern = async () => {
if (isQueryEnhancementEnabled && query?.dataset) {
const pattern = await data.indexPatterns.get(query.dataset.id);
if (isQueryEnhancementEnabled && query.dataset) {
let pattern = await data.indexPatterns.get(
query.dataset.id,
query.dataset.type !== 'INDEX_PATTERN'
);
if (!pattern) {
await data.query.queryString.getDatasetService().cacheDataset(query.dataset);
pattern = await data.indexPatterns.get(
query.dataset.id,
query.dataset.type !== 'INDEX_PATTERN'
);
}

if (isMounted && pattern) {
setIndexPattern(pattern);
Expand Down Expand Up @@ -95,7 +105,8 @@ export const useIndexPattern = (services: DiscoverViewServices) => {
store,
toastNotifications,
uiSettings,
query?.dataset,
query.dataset,
data.query.queryString,
]);

return indexPattern;
Expand Down

0 comments on commit 5fa8614

Please sign in to comment.