Add disableOnNumbers to settings reset

This commit is contained in:
Nymuxyzo 2025-06-23 21:44:26 +02:00
parent bd2bd0f33b
commit 5f62274f21
2 changed files with 50 additions and 2 deletions

View File

@ -751,6 +751,7 @@ pub fn apply_settings_to_builder(
builder.reset_min_word_len_two_typos();
builder.reset_exact_words();
builder.reset_exact_attributes();
builder.reset_disable_on_numbers();
}
Setting::NotSet => (),
}

View File

@ -247,6 +247,20 @@ async fn get_settings() {
assert_eq!(settings["prefixSearch"], json!("indexingTime"));
assert_eq!(settings["facetSearch"], json!(true));
assert_eq!(settings["embedders"], json!({}));
assert_eq!(settings["synonyms"], json!({}));
assert_eq!(
settings["typoTolerance"],
json!({
"enabled": true,
"minWordSizeForTypos": {
"oneTypo": 5,
"twoTypos": 9
},
"disableOnWords": [],
"disableOnAttributes": [],
"disableOnNumbers": false
})
);
}
#[actix_rt::test]
@ -426,8 +440,15 @@ async fn reset_all_settings() {
assert_eq!(code, 202);
server.wait_task(response.uid()).await.succeeded();
let (update_task,_status_code) = index
.update_settings(json!({"displayedAttributes": ["name", "age"], "searchableAttributes": ["name"], "stopWords": ["the"], "filterableAttributes": ["age"], "synonyms": {"puppy": ["dog", "doggo", "potat"] }}))
let (update_task, _status_code) = index
.update_settings(json!({
"displayedAttributes": ["name", "age"],
"searchableAttributes": ["name"],
"stopWords": ["the"],
"filterableAttributes": ["age"],
"synonyms": {"puppy": ["dog", "doggo", "potat"] },
"typoTolerance": {"disableOnNumbers": true}
}))
.await;
server.wait_task(update_task.uid()).await.succeeded();
let (response, code) = index.settings().await;
@ -437,6 +458,19 @@ async fn reset_all_settings() {
assert_eq!(response["stopWords"], json!(["the"]));
assert_eq!(response["synonyms"], json!({"puppy": ["dog", "doggo", "potat"] }));
assert_eq!(response["filterableAttributes"], json!(["age"]));
assert_eq!(
response["typoTolerance"],
json!({
"enabled": true,
"minWordSizeForTypos": {
"oneTypo": 5,
"twoTypos": 9
},
"disableOnWords": [],
"disableOnAttributes": [],
"disableOnNumbers": true
})
);
let (delete_task, _status_code) = index.delete_settings().await;
server.wait_task(delete_task.uid()).await.succeeded();
@ -448,6 +482,19 @@ async fn reset_all_settings() {
assert_eq!(response["stopWords"], json!([]));
assert_eq!(response["filterableAttributes"], json!([]));
assert_eq!(response["synonyms"], json!({}));
assert_eq!(
response["typoTolerance"],
json!({
"enabled": true,
"minWordSizeForTypos": {
"oneTypo": 5,
"twoTypos": 9
},
"disableOnWords": [],
"disableOnAttributes": [],
"disableOnNumbers": false
})
);
let (response, code) = index.get_document(1, None).await;
assert_eq!(code, 200);