Skip to content

Commit

Permalink
[ML] Allow index patterns containing commas in recogniser modules (#4…
Browse files Browse the repository at this point in the history
…3686) (#43739)

* [ML] Allow index patterns containing commas in recogniser modules

* fixing issue where only 'indexes' is the allowed datafeed index list
  • Loading branch information
jgowdyelastic authored Aug 22, 2019
1 parent 19b3941 commit c597b6c
Showing 1 changed file with 25 additions and 1 deletion.
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

0 comments on commit c597b6c

Please sign in to comment.