rename the search_cutoff parameter to search_cutoff_ms

This commit is contained in:
Tamo 2024-03-18 12:06:00 +01:00
parent 038c26c118
commit 6a0c399c2f
8 changed files with 39 additions and 38 deletions

View File

@ -277,7 +277,7 @@ pub(crate) mod test {
}),
pagination: Setting::NotSet,
embedders: Setting::NotSet,
search_cutoff: Setting::NotSet,
search_cutoff_ms: Setting::NotSet,
_kind: std::marker::PhantomData,
};
settings.check()

View File

@ -379,7 +379,7 @@ impl<T> From<v5::Settings<T>> for v6::Settings<v6::Unchecked> {
v5::Setting::NotSet => v6::Setting::NotSet,
},
embedders: v6::Setting::NotSet,
search_cutoff: v6::Setting::NotSet,
search_cutoff_ms: v6::Setting::NotSet,
_kind: std::marker::PhantomData,
}
}

View File

@ -204,7 +204,7 @@ pub struct Settings<T> {
pub embedders: Setting<BTreeMap<String, Setting<milli::vector::settings::EmbeddingSettings>>>,
#[serde(default, skip_serializing_if = "Setting::is_not_set")]
#[deserr(default, error = DeserrJsonError<InvalidSettingsSearchCutoff>)]
pub search_cutoff: Setting<u64>,
pub search_cutoff_ms: Setting<u64>,
#[serde(skip)]
#[deserr(skip)]
@ -230,7 +230,7 @@ impl Settings<Checked> {
faceting: Setting::Reset,
pagination: Setting::Reset,
embedders: Setting::Reset,
search_cutoff: Setting::Reset,
search_cutoff_ms: Setting::Reset,
_kind: PhantomData,
}
}
@ -253,7 +253,7 @@ impl Settings<Checked> {
faceting,
pagination,
embedders,
search_cutoff,
search_cutoff_ms,
..
} = self;
@ -274,7 +274,7 @@ impl Settings<Checked> {
faceting,
pagination,
embedders,
search_cutoff,
search_cutoff_ms,
_kind: PhantomData,
}
}
@ -321,7 +321,7 @@ impl Settings<Unchecked> {
faceting: self.faceting,
pagination: self.pagination,
embedders: self.embedders,
search_cutoff: self.search_cutoff,
search_cutoff_ms: self.search_cutoff_ms,
_kind: PhantomData,
}
}
@ -371,7 +371,7 @@ pub fn apply_settings_to_builder(
faceting,
pagination,
embedders,
search_cutoff,
search_cutoff_ms,
_kind,
} = settings;
@ -548,7 +548,7 @@ pub fn apply_settings_to_builder(
Setting::NotSet => (),
}
match search_cutoff {
match search_cutoff_ms {
Setting::Set(cutoff) => builder.set_search_cutoff(*cutoff),
Setting::Reset => builder.reset_search_cutoff(),
Setting::NotSet => (),
@ -641,7 +641,7 @@ pub fn settings(
.collect();
let embedders = if embedders.is_empty() { Setting::NotSet } else { Setting::Set(embedders) };
let search_cutoff = index.search_cutoff(rtxn)?;
let search_cutoff_ms = index.search_cutoff(rtxn)?;
Ok(Settings {
displayed_attributes: match displayed_attributes {
@ -669,7 +669,7 @@ pub fn settings(
faceting: Setting::Set(faceting),
pagination: Setting::Set(pagination),
embedders,
search_cutoff: match search_cutoff {
search_cutoff_ms: match search_cutoff_ms {
Some(cutoff) => Setting::Set(cutoff),
None => Setting::Reset,
},
@ -823,7 +823,7 @@ pub(crate) mod test {
faceting: Setting::NotSet,
pagination: Setting::NotSet,
embedders: Setting::NotSet,
search_cutoff: Setting::NotSet,
search_cutoff_ms: Setting::NotSet,
_kind: PhantomData::<Unchecked>,
};
@ -850,7 +850,7 @@ pub(crate) mod test {
faceting: Setting::NotSet,
pagination: Setting::NotSet,
embedders: Setting::NotSet,
search_cutoff: Setting::NotSet,
search_cutoff_ms: Setting::NotSet,
_kind: PhantomData::<Unchecked>,
};

View File

@ -626,19 +626,19 @@ fn embedder_analytics(
}
make_setting_route!(
"/search-cutoff",
"/search-cutoff-ms",
put,
u64,
meilisearch_types::deserr::DeserrJsonError<
meilisearch_types::error::deserr_codes::InvalidSettingsSearchCutoff,
>,
search_cutoff,
"searchCutoff",
search_cutoff_ms,
"searchCutoffMs",
analytics,
|setting: &Option<u64>, req: &HttpRequest| {
analytics.publish(
"Search Cutoff Updated".to_string(),
serde_json::json!({"search_cutoff": setting }),
serde_json::json!({"search_cutoff_ms": setting }),
Some(req),
);
}
@ -675,7 +675,7 @@ generate_configure!(
pagination,
faceting,
embedders,
search_cutoff
search_cutoff_ms
);
pub async fn update_all(
@ -787,7 +787,7 @@ pub async fn update_all(
"total": new_settings.synonyms.as_ref().set().map(|synonyms| synonyms.len()),
},
"embedders": crate::routes::indexes::settings::embedder_analytics(new_settings.embedders.as_ref().set()),
"search_cutoff": new_settings.search_cutoff.as_ref().set(),
"search_cutoff_ms": new_settings.search_cutoff_ms.as_ref().set(),
}),
Some(&req),
);

View File

@ -16,6 +16,7 @@ pub use server::{default_settings, Server};
pub struct Value(pub serde_json::Value);
impl Value {
#[track_caller]
pub fn uid(&self) -> u64 {
if let Some(uid) = self["uid"].as_u64() {
uid

View File

@ -78,7 +78,7 @@ async fn import_dump_v1_movie_raw() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -240,7 +240,7 @@ async fn import_dump_v1_movie_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -388,7 +388,7 @@ async fn import_dump_v1_rubygems_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -522,7 +522,7 @@ async fn import_dump_v2_movie_raw() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -668,7 +668,7 @@ async fn import_dump_v2_movie_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -813,7 +813,7 @@ async fn import_dump_v2_rubygems_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -947,7 +947,7 @@ async fn import_dump_v3_movie_raw() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -1093,7 +1093,7 @@ async fn import_dump_v3_movie_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -1238,7 +1238,7 @@ async fn import_dump_v3_rubygems_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -1372,7 +1372,7 @@ async fn import_dump_v4_movie_raw() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -1518,7 +1518,7 @@ async fn import_dump_v4_movie_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -1663,7 +1663,7 @@ async fn import_dump_v4_rubygems_with_settings() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###
);
@ -1908,7 +1908,7 @@ async fn import_dump_v6_containing_experimental_features() {
"pagination": {
"maxTotalHits": 1000
},
"searchCutoff": null
"searchCutoffMs": null
}
"###);

View File

@ -843,7 +843,7 @@ async fn test_degraded_score_details() {
index.add_documents(json!(documents), None).await;
// We can't really use anything else than 0ms here; otherwise, the test will get flaky.
let (res, _code) = index.update_settings(json!({ "searchCutoff": 0 })).await;
let (res, _code) = index.update_settings(json!({ "searchCutoffMs": 0 })).await;
index.wait_task(res.uid()).await;
index
@ -855,7 +855,7 @@ async fn test_degraded_score_details() {
}),
|response, code| {
meili_snap::snapshot!(code, @"200 OK");
meili_snap::snapshot!(meili_snap::json_string!(response), @r###"
meili_snap::snapshot!(meili_snap::json_string!(response, { ".processingTimeMs" => "[duration]" }), @r###"
{
"hits": [
{
@ -905,7 +905,7 @@ async fn test_degraded_score_details() {
}
],
"query": "b",
"processingTimeMs": 0,
"processingTimeMs": "[duration]",
"limit": 20,
"offset": 0,
"estimatedTotalHits": 3

View File

@ -35,7 +35,7 @@ static DEFAULT_SETTINGS_VALUES: Lazy<HashMap<&'static str, Value>> = Lazy::new(|
"maxTotalHits": json!(1000),
}),
);
map.insert("search_cutoff", json!(null));
map.insert("search_cutoff_ms", json!(null));
map
});
@ -85,7 +85,7 @@ async fn get_settings() {
})
);
assert_eq!(settings["proximityPrecision"], json!("byWord"));
assert_eq!(settings["searchCutoff"], json!(null));
assert_eq!(settings["searchCutoffMs"], json!(null));
}
#[actix_rt::test]
@ -288,7 +288,7 @@ test_setting_routes!(
synonyms put,
pagination patch,
faceting patch,
search_cutoff put
search_cutoff_ms put
);
#[actix_rt::test]