Fix bulk indexing error
This commit is contained in:
parent
944afc977d
commit
f2cb0fc97f
|
@ -112,16 +112,17 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
|
||||||
logger.info(`Bulk indexing ${elements.length} elements in ${this.indexName}`)
|
logger.info(`Bulk indexing ${elements.length} elements in ${this.indexName}`)
|
||||||
|
|
||||||
this.bulkProcessEnqueuedTask = await this.indexElements(elements)
|
this.bulkProcessEnqueuedTask = await this.indexElements(elements)
|
||||||
|
|
||||||
this.bulkIndexationTimer = undefined
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error({ err }, 'Cannot schedule bulk indexation')
|
logger.error({ err }, 'Cannot schedule bulk indexation')
|
||||||
|
} finally {
|
||||||
|
this.bulkIndexationTimer = undefined
|
||||||
}
|
}
|
||||||
}, CONFIG.INDEXER.BULK_INDEXATION_INTERVAL_MS)
|
}, CONFIG.INDEXER.BULK_INDEXATION_INTERVAL_MS)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async indexElements (elements: T[]) {
|
private async indexElements (elements: T[]) {
|
||||||
const documents = elements.map(e => this.formatterFn(e))
|
const documents = elements.map(e => this.formatterFn(e))
|
||||||
|
.filter(e => !!e)
|
||||||
|
|
||||||
const result = await client.index(this.indexName).updateDocuments(documents, { primaryKey: this.primaryKey.toString() })
|
const result = await client.index(this.indexName).updateDocuments(documents, { primaryKey: this.primaryKey.toString() })
|
||||||
logger.debug(result, 'Indexed ' + documents.length + ' documents in ' + this.indexName)
|
logger.debug(result, 'Indexed ' + documents.length + ' documents in ' + this.indexName)
|
||||||
|
|
Loading…
Reference in New Issue