Fix bulk indexing error

This commit is contained in:
Chocobozzz 2024-02-09 10:14:04 +01:00
parent 944afc977d
commit f2cb0fc97f
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 3 additions and 2 deletions

View File

@ -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)