diff --git a/crates/index-scheduler/src/features.rs b/crates/index-scheduler/src/features.rs index c6c17b2d5..43101560a 100644 --- a/crates/index-scheduler/src/features.rs +++ b/crates/index-scheduler/src/features.rs @@ -86,6 +86,19 @@ impl RoFeatures { .into()) } } + + pub fn check_proxy_search(&self, disabled_action: &'static str) -> Result<()> { + if self.runtime.proxy_search { + Ok(()) + } else { + Err(FeatureNotEnabledError { + disabled_action, + feature: "proxy search", + issue_link: "https://github.com/orgs/meilisearch/discussions/805", + } + .into()) + } + } } impl FeatureData { diff --git a/crates/meilisearch-types/src/features.rs b/crates/meilisearch-types/src/features.rs index ba67f996b..7cdf8f1cf 100644 --- a/crates/meilisearch-types/src/features.rs +++ b/crates/meilisearch-types/src/features.rs @@ -7,6 +7,7 @@ pub struct RuntimeTogglableFeatures { pub logs_route: bool, pub edit_documents_by_function: bool, pub contains_filter: bool, + pub proxy_search: bool, } #[derive(Default, Debug, Clone, Copy)] diff --git a/crates/meilisearch/src/analytics/segment_analytics.rs b/crates/meilisearch/src/analytics/segment_analytics.rs index 9fc212cc4..c815a4ad4 100644 --- a/crates/meilisearch/src/analytics/segment_analytics.rs +++ b/crates/meilisearch/src/analytics/segment_analytics.rs @@ -195,6 +195,7 @@ struct Infos { experimental_reduce_indexing_memory_usage: bool, experimental_max_number_of_batched_tasks: usize, experimental_limit_batched_tasks_total_size: u64, + experimental_proxy_search: bool, gpu_enabled: bool, db_path: bool, import_dump: bool, @@ -285,6 +286,7 @@ impl Infos { logs_route, edit_documents_by_function, contains_filter, + proxy_search, } = features; // We're going to override every sensible information. @@ -302,6 +304,7 @@ impl Infos { experimental_replication_parameters, experimental_enable_logs_route: experimental_enable_logs_route | logs_route, experimental_reduce_indexing_memory_usage, + experimental_proxy_search: proxy_search, gpu_enabled: meilisearch_types::milli::vector::is_cuda_enabled(), db_path: db_path != PathBuf::from("./data.ms"), import_dump: import_dump.is_some(), diff --git a/crates/meilisearch/src/routes/features.rs b/crates/meilisearch/src/routes/features.rs index f46bda5a0..d4e3908d6 100644 --- a/crates/meilisearch/src/routes/features.rs +++ b/crates/meilisearch/src/routes/features.rs @@ -50,6 +50,7 @@ pub fn configure(cfg: &mut web::ServiceConfig) { logs_route: Some(false), edit_documents_by_function: Some(false), contains_filter: Some(false), + proxy_search: Some(false), })), (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( { @@ -88,6 +89,8 @@ pub struct RuntimeTogglableFeatures { pub edit_documents_by_function: Option, #[deserr(default)] pub contains_filter: Option, + #[deserr(default)] + pub proxy_search: Option, } impl From for RuntimeTogglableFeatures { @@ -97,6 +100,7 @@ impl From for RuntimeTogg logs_route, edit_documents_by_function, contains_filter, + proxy_search, } = value; Self { @@ -104,6 +108,7 @@ impl From for RuntimeTogg logs_route: Some(logs_route), edit_documents_by_function: Some(edit_documents_by_function), contains_filter: Some(contains_filter), + proxy_search: Some(proxy_search), } } } @@ -114,6 +119,7 @@ pub struct PatchExperimentalFeatureAnalytics { logs_route: bool, edit_documents_by_function: bool, contains_filter: bool, + proxy_search: bool, } impl Aggregate for PatchExperimentalFeatureAnalytics { @@ -127,6 +133,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics { logs_route: new.logs_route, edit_documents_by_function: new.edit_documents_by_function, contains_filter: new.contains_filter, + proxy_search: new.proxy_search, }) } @@ -149,6 +156,7 @@ impl Aggregate for PatchExperimentalFeatureAnalytics { logs_route: Some(false), edit_documents_by_function: Some(false), contains_filter: Some(false), + proxy_search: Some(false), })), (status = 401, description = "The authorization header is missing", body = ResponseError, content_type = "application/json", example = json!( { @@ -181,6 +189,7 @@ async fn patch_features( .edit_documents_by_function .unwrap_or(old_features.edit_documents_by_function), contains_filter: new_features.0.contains_filter.unwrap_or(old_features.contains_filter), + proxy_search: new_features.0.proxy_search.unwrap_or(old_features.proxy_search), }; // explicitly destructure for analytics rather than using the `Serialize` implementation, because @@ -191,6 +200,7 @@ async fn patch_features( logs_route, edit_documents_by_function, contains_filter, + proxy_search, } = new_features; analytics.publish( @@ -199,6 +209,7 @@ async fn patch_features( logs_route, edit_documents_by_function, contains_filter, + proxy_search, }, &req, );