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] Allow index patterns containing commas in recogniser modules #43686

Merged
Changes from all 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 @@ -674,9 +674,33 @@ export class DataRecognizer {
// if an override index pattern has been specified,
// update all of the datafeeds.
updateDatafeedIndices(moduleConfig) {
// if the supplied index pattern contains a comma, split into multiple indices and
// add each one to the datafeed
const indexPatternNames = this.indexPatternName.includes(',')
? this.indexPatternName.split(',').map(i => i.trim())
: [this.indexPatternName];

moduleConfig.datafeeds.forEach((df) => {
df.config.indexes = df.config.indexes.map(index => (index === INDEX_PATTERN_NAME ? this.indexPatternName : index));
const newIndices = [];
// the datafeed can contain indexes and indices
const currentIndices = df.config.indexes !== undefined ? df.config.indexes : df.config.indices;

currentIndices.forEach(index => {
if (index === INDEX_PATTERN_NAME) {
// the datafeed index is INDEX_PATTERN_NAME, so replace it with index pattern(s)
// supplied by the user or the default one from the manifest
newIndices.push(...indexPatternNames);
} else {
// otherwise keep using the index from the datafeed json
newIndices.push(index);
}
});

// just in case indexes was used, delete it in favour of indices
delete df.config.indexes;
df.config.indices = newIndices;
});
moduleConfig.datafeeds;
}

// loop through the custom urls in each job and replace the INDEX_PATTERN_ID
Expand Down