mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-11 14:04:31 +01:00
Hard or soft delete according to the deletion strategy
This commit is contained in:
parent
fc7618d49b
commit
e2ae3b24aa
@ -186,6 +186,9 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
||||
|
||||
soft_deleted_docids |= &self.to_delete_docids;
|
||||
|
||||
// decide for a hard or soft deletion depending on the strategy
|
||||
let soft_deletion = match self.strategy {
|
||||
DeletionStrategy::Dynamic => {
|
||||
// if we have less documents to delete than the threshold we simply save them in
|
||||
// the `soft_deleted_documents_ids` bitmap and early exit.
|
||||
let size_used = self.index.used_size()?;
|
||||
@ -208,11 +211,14 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
|
||||
// We run the deletion.
|
||||
// - With 100Go of disk and 50Go used including 15Go of soft-deleted documents
|
||||
// We run the deletion.
|
||||
percentage_available > 10 && percentage_used_by_soft_deleted_documents < 10
|
||||
}
|
||||
DeletionStrategy::AlwaysSoft => true,
|
||||
DeletionStrategy::AlwaysHard => false,
|
||||
};
|
||||
|
||||
if !self.disable_soft_deletion
|
||||
&& percentage_available > 10
|
||||
&& percentage_used_by_soft_deleted_documents < 10
|
||||
{
|
||||
if soft_deletion {
|
||||
// Keep the soft-deleted in the DB
|
||||
self.index.put_soft_deleted_documents_ids(self.wtxn, &soft_deleted_docids)?;
|
||||
return Ok(DetailedDocumentDeletionResult {
|
||||
deleted_documents: self.to_delete_docids.len(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user