Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch delete documents instead of deleting them one by one in update lifecycle. #632

Open
bidoubiwa opened this issue Jan 4, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bidoubiwa
Copy link
Contributor

See #611

Currently when you update multiple entries, it trigger the afterUpdateMany lifecycle.

This lifecycle uses

updateEntriesInMeilisearch: async function ({ contentType, entries }) {
to update the entries in Meilisearch.

To ensure the entry should be present in Meilisearch, the above function uses sanitizeEntries

const sanitized = await sanitizeEntries({

For some reason, these checks are done one entry at the time and if the entry should not be in Meilisearch, it is deleted. The deletion happens even if the entry was not already present in Meilisearch. This is done to avoid having to first getting the document in Meilisearch and then delete it. Problem is, the entries are deleted one by one. Thus, if you update X documents that are in draft mode for example, they are deleted one by one from Meilisearch. So, X requests are made to Meilisearch.

Now, instead of deleting them one by one, the entries that should be deleted should be deleted in one batch.
Instead of doing this:

return client.index(indexUid).deleteDocument(

We should use deleteDocuments.

@qaqland
Copy link

qaqland commented Dec 19, 2023

DANGER

This endpoint will be deprecated in the near future. Consider using POST /indexes/{index_uid}/documents/delete instead .

In your link, it shows this🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants