diff --git a/x-pack/plugins/reporting/server/lib/store/store.ts b/x-pack/plugins/reporting/server/lib/store/store.ts index c2246441c29f..d88f8ca9096b 100644 --- a/x-pack/plugins/reporting/server/lib/store/store.ts +++ b/x-pack/plugins/reporting/server/lib/store/store.ts @@ -73,7 +73,7 @@ const sourceDoc = (doc: Partial): Partial => { }; }; -const esDoc = ( +const esDocForUpdate = ( report: SavedReport, doc: Partial ): Parameters[0] => { @@ -82,7 +82,7 @@ const esDoc = ( index: report._index, if_seq_no: report._seq_no, if_primary_term: report._primary_term, - refresh: false, + refresh: 'wait_for' as estypes.Refresh, body: { doc }, }; }; @@ -178,7 +178,7 @@ export class ReportingStore { const doc = { index: report._index!, id: report._id, - refresh: false, + refresh: 'wait_for' as estypes.Refresh, body: { ...report.toReportSource(), ...sourceDoc({ @@ -309,7 +309,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to processing! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err; @@ -341,7 +341,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to failed! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err; @@ -363,7 +363,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to failed! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err; @@ -391,7 +391,7 @@ export class ReportingStore { let body: UpdateResponse; try { const client = await this.getClient(); - body = await client.update(esDoc(report, doc)); + body = await client.update(esDocForUpdate(report, doc)); } catch (err) { this.logError(`Error in updating status to complete! Report: ${jobDebugMessage(report)}`, err, report); // prettier-ignore throw err;