From bcd0c5f5a418b87a609b41fae55b26d63bd4d154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Thu, 4 Jul 2024 15:52:10 +0200 Subject: [PATCH] Support DocumentEdition in dumps --- dump/src/lib.rs | 14 ++++++++------ index-scheduler/src/lib.rs | 8 ++++++++ meilisearch-types/src/tasks.rs | 26 +++++++++++++------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/dump/src/lib.rs b/dump/src/lib.rs index 7a8e9f02c..722633ec6 100644 --- a/dump/src/lib.rs +++ b/dump/src/lib.rs @@ -104,6 +104,11 @@ pub enum KindDump { DocumentDeletionByFilter { filter: serde_json::Value, }, + DocumentEdition { + filter: Option, + context: Option>, + function: String, + }, Settings { settings: Box>, is_deletion: bool, @@ -166,18 +171,15 @@ impl From for KindDump { documents_count, allow_index_creation, }, - KindWithContent::DocumentEdition { .. } => KindDump::DocumentImport { - primary_key: None, - method: IndexDocumentsMethod::UpdateDocuments, - documents_count: 0, - allow_index_creation: false, - }, KindWithContent::DocumentDeletion { documents_ids, .. } => { KindDump::DocumentDeletion { documents_ids } } KindWithContent::DocumentDeletionByFilter { filter_expr, .. } => { KindDump::DocumentDeletionByFilter { filter: filter_expr } } + KindWithContent::DocumentEdition { filter_expr, context, function, .. } => { + KindDump::DocumentEdition { filter: filter_expr, context, function } + } KindWithContent::DocumentClear { .. } => KindDump::DocumentClear, KindWithContent::SettingsUpdate { new_settings, diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 253de0964..da57bfc9b 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -1603,6 +1603,14 @@ impl<'a> Dump<'a> { index_uid: task.index_uid.ok_or(Error::CorruptedDump)?, } } + KindDump::DocumentEdition { filter, context, function } => { + KindWithContent::DocumentEdition { + index_uid: task.index_uid.ok_or(Error::CorruptedDump)?, + filter_expr: filter, + context, + function, + } + } KindDump::DocumentClear => KindWithContent::DocumentClear { index_uid: task.index_uid.ok_or(Error::CorruptedDump)?, }, diff --git a/meilisearch-types/src/tasks.rs b/meilisearch-types/src/tasks.rs index a4aa67991..1dd6d3fbf 100644 --- a/meilisearch-types/src/tasks.rs +++ b/meilisearch-types/src/tasks.rs @@ -97,12 +97,6 @@ pub enum KindWithContent { documents_count: u64, allow_index_creation: bool, }, - DocumentEdition { - index_uid: String, - filter_expr: Option, - context: Option, - function: String, - }, DocumentDeletion { index_uid: String, documents_ids: Vec, @@ -111,6 +105,12 @@ pub enum KindWithContent { index_uid: String, filter_expr: serde_json::Value, }, + DocumentEdition { + index_uid: String, + filter_expr: Option, + context: Option, + function: String, + }, DocumentClear { index_uid: String, }, @@ -534,13 +534,6 @@ pub enum Details { received_documents: u64, indexed_documents: Option, }, - DocumentEdition { - deleted_documents: Option, - edited_documents: Option, - original_filter: Option, - context: Option, - function: String, - }, SettingsUpdate { settings: Box>, }, @@ -555,6 +548,13 @@ pub enum Details { original_filter: String, deleted_documents: Option, }, + DocumentEdition { + deleted_documents: Option, + edited_documents: Option, + original_filter: Option, + context: Option, + function: String, + }, ClearAll { deleted_documents: Option, },