mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-01-11 05:54:30 +01:00
Implement the DocumentClear batch operation
This commit is contained in:
parent
025bb5f616
commit
5174c78f87
@ -43,6 +43,7 @@ pub(crate) enum Batch {
|
|||||||
index_uid: String,
|
index_uid: String,
|
||||||
cleared_tasks: Vec<Task>,
|
cleared_tasks: Vec<Task>,
|
||||||
|
|
||||||
|
// TODO what's that boolean, does it mean that it removes things or what?
|
||||||
settings: Vec<(bool, Settings<Unchecked>)>,
|
settings: Vec<(bool, Settings<Unchecked>)>,
|
||||||
settings_tasks: Vec<Task>,
|
settings_tasks: Vec<Task>,
|
||||||
},
|
},
|
||||||
@ -53,6 +54,7 @@ pub(crate) enum Batch {
|
|||||||
content_files: Vec<Uuid>,
|
content_files: Vec<Uuid>,
|
||||||
document_addition_tasks: Vec<Task>,
|
document_addition_tasks: Vec<Task>,
|
||||||
|
|
||||||
|
// TODO what's that boolean, does it mean that it removes things or what?
|
||||||
settings: Vec<(bool, Settings<Unchecked>)>,
|
settings: Vec<(bool, Settings<Unchecked>)>,
|
||||||
settings_tasks: Vec<Task>,
|
settings_tasks: Vec<Task>,
|
||||||
},
|
},
|
||||||
@ -63,6 +65,7 @@ pub(crate) enum Batch {
|
|||||||
content_files: Vec<Uuid>,
|
content_files: Vec<Uuid>,
|
||||||
document_update_tasks: Vec<Task>,
|
document_update_tasks: Vec<Task>,
|
||||||
|
|
||||||
|
// TODO what's that boolean, does it mean that it removes things or what?
|
||||||
settings: Vec<(bool, Settings<Unchecked>)>,
|
settings: Vec<(bool, Settings<Unchecked>)>,
|
||||||
settings_tasks: Vec<Task>,
|
settings_tasks: Vec<Task>,
|
||||||
},
|
},
|
||||||
@ -429,7 +432,27 @@ impl IndexScheduler {
|
|||||||
Batch::Cancel(_) => todo!(),
|
Batch::Cancel(_) => todo!(),
|
||||||
Batch::Snapshot(_) => todo!(),
|
Batch::Snapshot(_) => todo!(),
|
||||||
Batch::Dump(_) => todo!(),
|
Batch::Dump(_) => todo!(),
|
||||||
Batch::DocumentClear { tasks, .. } => todo!(),
|
Batch::DocumentClear {
|
||||||
|
index_uid,
|
||||||
|
mut tasks,
|
||||||
|
} => {
|
||||||
|
let rtxn = self.env.read_txn()?;
|
||||||
|
let index = self.index_mapper.index(&rtxn, &index_uid)?;
|
||||||
|
rtxn.abort()?;
|
||||||
|
|
||||||
|
let ret = index.clear_documents();
|
||||||
|
for task in &mut tasks {
|
||||||
|
task.details = Some(Details::ClearAll {
|
||||||
|
// TODO where can I find this information of how many documents did we delete?
|
||||||
|
deleted_documents: None,
|
||||||
|
});
|
||||||
|
if let Err(ref error) = ret {
|
||||||
|
task.error = Some(error.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(tasks)
|
||||||
|
}
|
||||||
// TODO we should merge both document import with a method field
|
// TODO we should merge both document import with a method field
|
||||||
Batch::DocumentAddition {
|
Batch::DocumentAddition {
|
||||||
index_uid,
|
index_uid,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user