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 categorization job view examples link when datafeed uses multiple indices #100789

Merged
merged 3 commits into from
May 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -232,6 +232,7 @@ class LinksMenuUI extends Component {
}
const categorizationFieldName = job.analysis_config.categorization_field_name;
const datafeedIndices = job.datafeed_config.indices;

// Find the type of the categorization field i.e. text (preferred) or keyword.
// Uses the first matching field found in the list of indices in the datafeed_config.
// attempt to load the field type using each index. we have to do it this way as _field_caps
Expand Down Expand Up @@ -349,7 +350,7 @@ class LinksMenuUI extends Component {
getFieldTypeFromMapping(index, categorizationFieldName)
.then((resp) => {
if (resp !== '') {
createAndOpenUrl(index, resp);
createAndOpenUrl(datafeedIndices.join(), resp);
} else {
i++;
if (i < datafeedIndices.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { DASHBOARD_APP_URL_GENERATOR } from '../../../../../../../../src/plugins
import { getPartitioningFieldNames } from '../../../../../common/util/job_utils';
import { parseInterval } from '../../../../../common/util/parse_interval';
import { replaceTokensInUrlValue, isValidLabel } from '../../../util/custom_url_utils';
import { getIndexPatternIdFromName } from '../../../util/index_utils';
import { ml } from '../../../services/ml_api_service';
import { mlJobService } from '../../../services/job_service';
import { escapeForElasticsearchQuery } from '../../../util/string_utils';
Expand All @@ -38,7 +39,7 @@ export function getNewCustomUrlDefaults(job, dashboards, indexPatterns) {
}

// For the Discover option, set the default index pattern to that
// which matches the (first) index configured in the job datafeed.
// which matches the indices configured in the job datafeed.
const datafeedConfig = job.datafeed_config;
if (
indexPatterns !== undefined &&
Expand All @@ -47,16 +48,9 @@ export function getNewCustomUrlDefaults(job, dashboards, indexPatterns) {
datafeedConfig.indices !== undefined &&
datafeedConfig.indices.length > 0
) {
const datafeedIndex = datafeedConfig.indices[0];
let defaultIndexPattern = indexPatterns.find((indexPattern) => {
return indexPattern.title === datafeedIndex;
});

if (defaultIndexPattern === undefined) {
defaultIndexPattern = indexPatterns[0];
}

kibanaSettings.discoverIndexPatternId = defaultIndexPattern.id;
const defaultIndexPatternId =
getIndexPatternIdFromName(datafeedConfig.indices.join()) ?? indexPatterns[0].id;
kibanaSettings.discoverIndexPatternId = defaultIndexPatternId;
}

return {
Expand Down