From 2c025e02c9ee583d8f4535f0b1e04a65f7dfa813 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 19 Jul 2016 12:49:27 -0700 Subject: [PATCH] refresh the index after adding job makes the job searchable after the creation event emits --- src/job.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/job.js b/src/job.js index 01120ef..b478492 100644 --- a/src/job.js +++ b/src/job.js @@ -58,7 +58,13 @@ export default class Job extends events.EventEmitter { version: doc._version, }; this.debug(`Job created in index ${this.index}`); - this.emit(contstants.EVENT_JOB_CREATED, this.document); + + return this.client.indices.refresh({ + index: this.index + }).then(() => { + this.debug(`Job index refreshed ${this.index}`); + this.emit(contstants.EVENT_JOB_CREATED, this.document); + }); }) .catch((err) => { this.debug('Job creation failed', err);