diff --git a/meilisearch/src/routes/tasks.rs b/meilisearch/src/routes/tasks.rs index cab0f7197..4a2656982 100644 --- a/meilisearch/src/routes/tasks.rs +++ b/meilisearch/src/routes/tasks.rs @@ -99,7 +99,7 @@ pub struct DetailsView { #[serde(skip_serializing_if = "Option::is_none")] pub deleted_tasks: Option>, #[serde(skip_serializing_if = "Option::is_none")] - pub original_filter: Option, + pub original_filter: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub dump_uid: Option>, #[serde(skip_serializing_if = "Option::is_none")] @@ -131,12 +131,13 @@ impl From
for DetailsView { } => DetailsView { provided_ids: Some(received_document_ids), deleted_documents: Some(deleted_documents), + original_filter: Some(None), ..DetailsView::default() }, Details::DocumentDeletionByFilter { original_filter, deleted_documents } => { DetailsView { provided_ids: Some(0), - original_filter: Some(original_filter), + original_filter: Some(Some(original_filter)), deleted_documents: Some(deleted_documents), ..DetailsView::default() } @@ -148,7 +149,7 @@ impl From
for DetailsView { DetailsView { matched_tasks: Some(matched_tasks), canceled_tasks: Some(canceled_tasks), - original_filter: Some(original_filter), + original_filter: Some(Some(original_filter)), ..DetailsView::default() } } @@ -156,7 +157,7 @@ impl From
for DetailsView { DetailsView { matched_tasks: Some(matched_tasks), deleted_tasks: Some(deleted_tasks), - original_filter: Some(original_filter), + original_filter: Some(Some(original_filter)), ..DetailsView::default() } } diff --git a/meilisearch/tests/tasks/mod.rs b/meilisearch/tests/tasks/mod.rs index e9b5a2325..4ac134871 100644 --- a/meilisearch/tests/tasks/mod.rs +++ b/meilisearch/tests/tasks/mod.rs @@ -413,7 +413,7 @@ async fn test_summarized_document_addition_or_update() { } #[actix_web::test] -async fn test_summarized_delete_batch() { +async fn test_summarized_delete_documents_by_batch() { let server = Server::new().await; let index = server.index("test"); index.delete_batch(vec![1, 2, 3]).await; @@ -430,7 +430,8 @@ async fn test_summarized_delete_batch() { "canceledBy": null, "details": { "providedIds": 3, - "deletedDocuments": 0 + "deletedDocuments": 0, + "originalFilter": null }, "error": { "message": "Index `test` not found.", @@ -460,7 +461,8 @@ async fn test_summarized_delete_batch() { "canceledBy": null, "details": { "providedIds": 1, - "deletedDocuments": 0 + "deletedDocuments": 0, + "originalFilter": null }, "error": null, "duration": "[duration]", @@ -472,7 +474,100 @@ async fn test_summarized_delete_batch() { } #[actix_web::test] -async fn test_summarized_delete_document() { +async fn test_summarized_delete_documents_by_filter() { + let server = Server::new().await; + let index = server.index("test"); + + index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; + index.wait_task(0).await; + let (task, _) = index.get_task(0).await; + assert_json_snapshot!(task, + { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }, + @r###" + { + "uid": 0, + "indexUid": "test", + "status": "failed", + "type": "documentDeletion", + "canceledBy": null, + "details": { + "providedIds": 0, + "deletedDocuments": 0, + "originalFilter": "\"doggo = bernese\"" + }, + "error": { + "message": "Index `test` not found.", + "code": "index_not_found", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#index_not_found" + }, + "duration": "[duration]", + "enqueuedAt": "[date]", + "startedAt": "[date]", + "finishedAt": "[date]" + } + "###); + + index.create(None).await; + index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; + index.wait_task(2).await; + let (task, _) = index.get_task(2).await; + assert_json_snapshot!(task, + { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }, + @r###" + { + "uid": 2, + "indexUid": "test", + "status": "failed", + "type": "documentDeletion", + "canceledBy": null, + "details": { + "providedIds": 0, + "deletedDocuments": 0, + "originalFilter": "\"doggo = bernese\"" + }, + "error": { + "message": "Attribute `doggo` is not filterable. This index does not have configured filterable attributes.\n1:6 doggo = bernese", + "code": "invalid_document_filter", + "type": "invalid_request", + "link": "https://docs.meilisearch.com/errors#invalid_document_filter" + }, + "duration": "[duration]", + "enqueuedAt": "[date]", + "startedAt": "[date]", + "finishedAt": "[date]" + } + "###); + + index.update_settings(json!({ "filterableAttributes": ["doggo"] })).await; + index.delete_document_by_filter(json!({ "filter": "doggo = bernese" })).await; + index.wait_task(4).await; + let (task, _) = index.get_task(4).await; + assert_json_snapshot!(task, + { ".duration" => "[duration]", ".enqueuedAt" => "[date]", ".startedAt" => "[date]", ".finishedAt" => "[date]" }, + @r###" + { + "uid": 4, + "indexUid": "test", + "status": "succeeded", + "type": "documentDeletion", + "canceledBy": null, + "details": { + "providedIds": 0, + "deletedDocuments": 0, + "originalFilter": "\"doggo = bernese\"" + }, + "error": null, + "duration": "[duration]", + "enqueuedAt": "[date]", + "startedAt": "[date]", + "finishedAt": "[date]" + } + "###); +} + +#[actix_web::test] +async fn test_summarized_delete_document_by_id() { let server = Server::new().await; let index = server.index("test"); index.delete_document(1).await; @@ -489,7 +584,8 @@ async fn test_summarized_delete_document() { "canceledBy": null, "details": { "providedIds": 1, - "deletedDocuments": 0 + "deletedDocuments": 0, + "originalFilter": null }, "error": { "message": "Index `test` not found.", @@ -519,7 +615,8 @@ async fn test_summarized_delete_document() { "canceledBy": null, "details": { "providedIds": 1, - "deletedDocuments": 0 + "deletedDocuments": 0, + "originalFilter": null }, "error": null, "duration": "[duration]",