Skip to content

Commit

Permalink
[ML] Fix categorization job view examples link when datafeed uses mul…
Browse files Browse the repository at this point in the history
…tiple indices
  • Loading branch information
peteharverson committed May 27, 2021
1 parent 1c4d338 commit 1e2b28c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
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

0 comments on commit 1e2b28c

Please sign in to comment.