-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] Fix for errors when loading data views which are missing index #147916
Merged
jgowdyelastic
merged 8 commits into
elastic:7.17
from
jgowdyelastic:fix-for-data-view-missing-index-errors
Jan 17, 2023
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ca72308
[ML] Fix for errors when loading data veiws which are missing index
jgowdyelastic afefe9d
adding comment
jgowdyelastic d694980
Merge branch '7.17' into fix-for-data-view-missing-index-errors
jgowdyelastic ab37293
fixing test types
jgowdyelastic b0d6ee9
Merge branch '7.17' into fix-for-data-view-missing-index-errors
jgowdyelastic 5086eff
fixing dfa delete hook
jgowdyelastic d7c4be5
Merge branch '7.17' into fix-for-data-view-missing-index-errors
jgowdyelastic 53a0563
Merge branch '7.17' into fix-for-data-view-missing-index-errors
jgowdyelastic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,25 @@ let indexPatternsContract: DataViewsContract | null = null; | |
export async function loadIndexPatterns(indexPatterns: DataViewsContract) { | ||
indexPatternsContract = indexPatterns; | ||
const dataViewsContract = getDataViews(); | ||
indexPatternCache = await dataViewsContract.find('*', 10000); | ||
const idsAndTitles = await dataViewsContract.getIdsWithTitle(); | ||
|
||
const dataViewsThatExist = ( | ||
await Promise.allSettled( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 5086eff |
||
// attempt to load the fields for every data view. | ||
// if the index doesn't exist an error is thrown which we can catch. | ||
// This is preferable to the get function which display an | ||
// error toast for every missing index. | ||
idsAndTitles.map(({ title }) => dataViewsContract.getFieldsForIndexPattern({ title })) | ||
) | ||
).reduce<string[]>((acc, { status }, i) => { | ||
if (status === 'fulfilled') { | ||
acc.push(idsAndTitles[i].id); | ||
} | ||
return acc; | ||
}, []); | ||
|
||
// load each data view which has a real index behind it. | ||
indexPatternCache = await Promise.all(dataViewsThatExist.map(dataViewsContract.get)); | ||
return indexPatternCache; | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now load all of the ids and titles of the data views and attempt to get the fields for them to work out if the index really exists.
Once we have this filtered list of ids for data views which do exist, we can load the actual data views.
It might be better to use an exists check rather than
getFieldsForIndexPattern
but that will add additional dependencies to this function.