From c8ee453b6c3ffdfb4149097d628c007b4dcceb4d Mon Sep 17 00:00:00 2001 From: Irevoire Date: Sat, 22 Oct 2022 15:59:30 +0200 Subject: [PATCH] fix the autobatched document deletion --- index-scheduler/src/batch.rs | 9 +++++---- meilisearch-http/tests/documents/add_documents.rs | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/index-scheduler/src/batch.rs b/index-scheduler/src/batch.rs index d23a0dbfd..cb12ecefa 100644 --- a/index-scheduler/src/batch.rs +++ b/index-scheduler/src/batch.rs @@ -72,7 +72,8 @@ pub(crate) enum IndexOperation { }, DocumentDeletion { index_uid: String, - documents: Vec, + // The vec associated with each document deletion tasks. + documents: Vec>, tasks: Vec, }, DocumentClear { @@ -222,7 +223,7 @@ impl IndexScheduler { for task in &tasks { match task.kind { KindWithContent::DocumentDeletion { ref documents_ids, .. } => { - documents.extend_from_slice(documents_ids) + documents.push(documents_ids.clone()) } _ => unreachable!(), } @@ -912,7 +913,7 @@ impl IndexScheduler { } IndexOperation::DocumentDeletion { index_uid: _, documents, mut tasks } => { let mut builder = milli::update::DeleteDocuments::new(index_wtxn, index)?; - documents.iter().for_each(|id| { + documents.iter().flatten().for_each(|id| { builder.delete_external_id(id); }); @@ -922,7 +923,7 @@ impl IndexScheduler { task.status = Status::Succeeded; task.details = Some(Details::DocumentDeletion { received_document_ids: documents.len(), - deleted_documents: Some(deleted_documents), + deleted_documents: Some(deleted_documents.min(documents.len() as u64)), }); } diff --git a/meilisearch-http/tests/documents/add_documents.rs b/meilisearch-http/tests/documents/add_documents.rs index b497fbf15..8dd3ba39a 100644 --- a/meilisearch-http/tests/documents/add_documents.rs +++ b/meilisearch-http/tests/documents/add_documents.rs @@ -560,7 +560,6 @@ async fn error_add_missing_payload_ndjson_documents() { let status_code = res.status(); let body = test::read_body(res).await; let response: Value = serde_json::from_slice(&body).unwrap_or_default(); - dbg!(&response); assert_eq!(status_code, 400); assert_eq!(response["message"], json!(r#"A ndjson payload is missing."#)); assert_eq!(response["code"], json!("missing_payload"));