diff --git a/index-scheduler/src/features.rs b/index-scheduler/src/features.rs index ae8e6728a..fbb273e54 100644 --- a/index-scheduler/src/features.rs +++ b/index-scheduler/src/features.rs @@ -68,6 +68,19 @@ impl RoFeatures { .into()) } } + + pub fn check_edit_documents_by_function(&self, disabled_action: &'static str) -> Result<()> { + if self.runtime.edit_documents_by_function { + Ok(()) + } else { + Err(FeatureNotEnabledError { + disabled_action, + feature: "edit documents by function", + issue_link: "https://github.com/orgs/meilisearch/discussions/762", + } + .into()) + } + } } impl FeatureData { diff --git a/meilisearch-types/src/features.rs b/meilisearch-types/src/features.rs index dda9dee51..f15a1c999 100644 --- a/meilisearch-types/src/features.rs +++ b/meilisearch-types/src/features.rs @@ -6,6 +6,7 @@ pub struct RuntimeTogglableFeatures { pub vector_store: bool, pub metrics: bool, pub logs_route: bool, + pub edit_documents_by_function: bool, } #[derive(Default, Debug, Clone, Copy)] diff --git a/meilisearch/src/routes/features.rs b/meilisearch/src/routes/features.rs index 0e02309fa..14aece10f 100644 --- a/meilisearch/src/routes/features.rs +++ b/meilisearch/src/routes/features.rs @@ -47,6 +47,8 @@ pub struct RuntimeTogglableFeatures { pub metrics: Option, #[deserr(default)] pub logs_route: Option, + #[deserr(default)] + pub edit_documents_by_function: Option, } async fn patch_features( @@ -66,13 +68,21 @@ async fn patch_features( vector_store: new_features.0.vector_store.unwrap_or(old_features.vector_store), metrics: new_features.0.metrics.unwrap_or(old_features.metrics), logs_route: new_features.0.logs_route.unwrap_or(old_features.logs_route), + edit_documents_by_function: new_features + .0 + .edit_documents_by_function + .unwrap_or(old_features.edit_documents_by_function), }; // explicitly destructure for analytics rather than using the `Serialize` implementation, because // the it renames to camelCase, which we don't want for analytics. // **Do not** ignore fields with `..` or `_` here, because we want to add them in the future. - let meilisearch_types::features::RuntimeTogglableFeatures { vector_store, metrics, logs_route } = - new_features; + let meilisearch_types::features::RuntimeTogglableFeatures { + vector_store, + metrics, + logs_route, + edit_documents_by_function, + } = new_features; analytics.publish( "Experimental features Updated".to_string(), @@ -80,6 +90,7 @@ async fn patch_features( "vector_store": vector_store, "metrics": metrics, "logs_route": logs_route, + "edit_documents_by_function": edit_documents_by_function, }), Some(&req), ); diff --git a/meilisearch/src/routes/indexes/documents.rs b/meilisearch/src/routes/indexes/documents.rs index 3b1dcba22..9faf8bc67 100644 --- a/meilisearch/src/routes/indexes/documents.rs +++ b/meilisearch/src/routes/indexes/documents.rs @@ -595,6 +595,11 @@ pub async fn edit_documents_by_function( analytics: web::Data, ) -> Result { debug!(parameters = ?params, "Edit documents by function"); + + index_scheduler + .features() + .check_edit_documents_by_function("Using the documents edit route")?; + let index_uid = IndexUid::try_from(index_uid.into_inner())?; let index_uid = index_uid.into_inner(); let params = params.into_inner();