refresh the index after adding job

makes the job searchable after the creation event emits
This commit is contained in:
2016-07-19 12:49:27 -07:00
parent 041af798a8
commit 2c025e02c9

View File

@@ -58,7 +58,13 @@ export default class Job extends events.EventEmitter {
version: doc._version, version: doc._version,
}; };
this.debug(`Job created in index ${this.index}`); 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) => { .catch((err) => {
this.debug('Job creation failed', err); this.debug('Job creation failed', err);