mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
Implement the DocumentDeletion batch operation
This commit is contained in:
parent
7a0f17c912
commit
a6a1043abb
@ -5,7 +5,7 @@ use crate::{
|
||||
};
|
||||
use index::{Settings, Unchecked};
|
||||
use milli::heed::RoTxn;
|
||||
use milli::update::{DocumentAdditionResult, IndexDocumentsMethod};
|
||||
use milli::update::{DocumentAdditionResult, DocumentDeletionResult, IndexDocumentsMethod};
|
||||
use uuid::Uuid;
|
||||
|
||||
pub(crate) enum Batch {
|
||||
@ -487,7 +487,32 @@ impl IndexScheduler {
|
||||
index_uid,
|
||||
documents,
|
||||
tasks,
|
||||
} => todo!(),
|
||||
} => {
|
||||
let rtxn = self.env.read_txn()?;
|
||||
let index = self.index_mapper.index(&rtxn, &index_uid)?;
|
||||
|
||||
let ret = index.delete_documents(&documents);
|
||||
for task in tasks {
|
||||
match ret {
|
||||
Ok(DocumentDeletionResult {
|
||||
deleted_documents,
|
||||
remaining_documents: _,
|
||||
}) => {
|
||||
// TODO we are assigning the same amount of documents to
|
||||
// all the tasks that are in the same batch. That's wrong!
|
||||
task.details = Some(Details::DocumentDeletion {
|
||||
received_document_ids: documents.len(),
|
||||
deleted_documents: Some(deleted_documents),
|
||||
});
|
||||
}
|
||||
Err(error) => {
|
||||
task.error = Some(error.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(tasks)
|
||||
}
|
||||
Batch::Settings {
|
||||
index_uid,
|
||||
settings,
|
||||
|
@ -327,6 +327,7 @@ pub enum Details {
|
||||
#[serde(rename_all = "camelCase")]
|
||||
DocumentDeletion {
|
||||
received_document_ids: usize,
|
||||
// TODO why is this optional?
|
||||
deleted_documents: Option<u64>,
|
||||
},
|
||||
#[serde(rename_all = "camelCase")]
|
||||
|
Loading…
Reference in New Issue
Block a user