Skip to content

Commit 0c166ed

Browse files
committed
feat(meilisearch-connector): update emptyOrDeleteIndex
to handle multiple indexes
1 parent 7957e33 commit 0c166ed

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

server/services/meilisearch/connector.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ module.exports = ({ strapi, adapter, config }) => {
396396
},
397397

398398
/**
399-
* Delete or empty an index depending if the contentType is part
399+
* Delete or empty all indexes of a contentType, depending if the contentType is part
400400
* of a composite index.
401401
*
402402
* @param {object} options
@@ -423,11 +423,15 @@ module.exports = ({ strapi, adapter, config }) => {
423423
const { apiKey, host } = await store.getCredentials()
424424
const client = Meilisearch({ apiKey, host })
425425

426-
const indexUid = config.getIndexNameOfContentType({ contentType })
427-
const { taskUid } = await client.index(indexUid).delete()
428-
429-
strapi.log.info(
430-
`A task to delete the Meilisearch index "${indexUid}" has been added to the queue (Task uid: ${taskUid}).`,
426+
const indexUids = config.getIndexNamesOfContentType({ contentType })
427+
await Promise.all(
428+
indexUids.map(async indexUid => {
429+
const { taskUid } = await client.index(indexUid).delete()
430+
strapi.log.info(
431+
`A task to delete the Meilisearch index "${indexUid}" has been added to the queue (Task uid: ${taskUid}).`,
432+
)
433+
return taskUid
434+
}),
431435
)
432436
}
433437

0 commit comments

Comments
 (0)