Skip to content

Commit

Permalink
[7.8] [Discover] Catch error when popularizeField fails (#62402) (#66594
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kertal authored May 16, 2020
1 parent 7cbe138 commit 30b0095
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ export class IndexPattern implements IIndexPattern {
}

async popularizeField(fieldName: string, unit = 1) {
/**
* This function is just used by Discover and it's high likely to be removed in the near future
* It doesn't use the save function to skip the error message that's displayed when
* a user adds several columns in a higher frequency that the changes can be persisted to ES
* resulting in 409 errors
*/
if (!this.id) return;
const field = this.fields.getByName(fieldName);
if (!field) {
return;
Expand All @@ -369,7 +376,15 @@ export class IndexPattern implements IIndexPattern {
return;
}
field.count = count;
await this.save();

try {
const res = await this.savedObjectsClient.update(type, this.id, this.prepBody(), {
version: this.version,
});
this.version = res._version;
} catch (e) {
// no need for an error message here
}
}

getNonScriptedFields() {
Expand Down

0 comments on commit 30b0095

Please sign in to comment.