Skip to content
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 Index data visualizer sometimes shows wrong doc count for saved searches #106007

Merged
merged 6 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,16 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
const parsedQueryString = parse(prevSearchString, { sort: false });

const getIndexPattern = async () => {
if (typeof parsedQueryString?.index === 'string') {
const indexPattern = await indexPatterns.get(parsedQueryString.index);
setCurrentIndexPattern(indexPattern);
}

if (typeof parsedQueryString?.savedSearchId === 'string') {
const savedSearchId = parsedQueryString.savedSearchId;
try {
const savedSearch = await savedObjectsClient.get('search', savedSearchId);
const indexPatternId = savedSearch.references.find((ref) => ref.type === 'index-pattern')
?.id;
if (indexPatternId !== undefined) {
if (indexPatternId !== undefined && savedSearch) {
try {
const indexPattern = await indexPatterns.get(indexPatternId);
setCurrentSavedSearch(savedSearch);
setCurrentIndexPattern(indexPattern);
} catch (e) {
toasts.addError(e, {
Expand All @@ -88,7 +84,6 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
});
}
}
setCurrentSavedSearch(savedSearch);
} catch (e) {
toasts.addError(e, {
title: i18n.translate('xpack.dataVisualizer.index.savedSearchErrorMessage', {
Expand All @@ -98,6 +93,11 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
});
}
}

if (typeof parsedQueryString?.index === 'string') {
const indexPattern = await indexPatterns.get(parsedQueryString.index);
setCurrentIndexPattern(indexPattern);
}
};
getIndexPattern();
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ export default function ({ getService }: FtrProviderContext) {
});
}

// FLAKY: https://github.com/elastic/kibana/issues/105087
describe.skip('index based', function () {
describe('index based', function () {
this.tags(['mlqa']);
before(async () => {
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote');
Expand Down