Skip to content

Commit 47c80a9

Browse files
committed
make typotolerance setting fields optional
1 parent da08977 commit 47c80a9

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

src/settings.rs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ pub struct MinWordSizeForTypos {
2323
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)]
2424
#[serde(rename_all = "camelCase")]
2525
pub struct TypoToleranceSettings {
26-
pub enabled: bool,
27-
pub disable_on_attributes: Vec<String>,
28-
pub disable_on_words: Vec<String>,
29-
pub min_word_size_for_typos: MinWordSizeForTypos,
26+
pub enabled: Option<bool>,
27+
pub disable_on_attributes: Option<Vec<String>>,
28+
pub disable_on_words: Option<Vec<String>>,
29+
pub min_word_size_for_typos: Option<MinWordSizeForTypos>,
3030
}
3131

3232
#[derive(Serialize, Deserialize, Default, Debug, Clone, Eq, PartialEq)]
@@ -1051,10 +1051,12 @@ impl Index {
10511051
/// let mut index = client.index("set_typo_tolerance");
10521052
///
10531053
/// let mut typo_tolerance = TypoToleranceSettings {
1054-
/// enabled: true,
1055-
/// disable_on_attributes: vec!(),
1056-
/// disable_on_words: vec!(),
1057-
/// min_word_size_for_typos: MinWordSizeForTypos { one_typo : 1, two_typos: 2},
1054+
/// enabled: Some(true),
1055+
/// disable_on_attributes: None,
1056+
/// disable_on_words: None,
1057+
/// min_word_size_for_typos: Some(MinWordSizeForTypos {
1058+
/// one_typo: 5,
1059+
/// two_typos: 9})
10581060
/// };
10591061
///
10601062
/// let task = index.set_typo_tolerance(&typo_tolerance).await.unwrap();
@@ -1562,13 +1564,13 @@ mod tests {
15621564
#[meilisearch_test]
15631565
async fn test_get_typo_tolerance(index: Index) {
15641566
let typo_tolerance = TypoToleranceSettings {
1565-
enabled: true,
1566-
disable_on_attributes: vec![],
1567-
disable_on_words: vec![],
1568-
min_word_size_for_typos: MinWordSizeForTypos {
1567+
enabled: Some(true),
1568+
disable_on_attributes: None,
1569+
disable_on_words: None,
1570+
min_word_size_for_typos: Some(MinWordSizeForTypos {
15691571
one_typo: 5,
15701572
two_typos: 9,
1571-
},
1573+
}),
15721574
};
15731575

15741576
let res = index.get_typo_tolerance().await.unwrap();
@@ -1579,13 +1581,13 @@ mod tests {
15791581
#[meilisearch_test]
15801582
async fn test_set_typo_tolerance(client: Client, index: Index) {
15811583
let typo_tolerance = TypoToleranceSettings {
1582-
enabled: false,
1583-
disable_on_attributes: vec![],
1584-
disable_on_words: vec![],
1585-
min_word_size_for_typos: MinWordSizeForTypos {
1584+
enabled: Some(false),
1585+
disable_on_attributes: None,
1586+
disable_on_words: None,
1587+
min_word_size_for_typos: Some(MinWordSizeForTypos {
15861588
one_typo: 6,
15871589
two_typos: 9,
1588-
},
1590+
}),
15891591
};
15901592
let task_info = index.set_typo_tolerance(&typo_tolerance).await.unwrap();
15911593
client.wait_for_task(task_info, None, None).await.unwrap();
@@ -1598,22 +1600,22 @@ mod tests {
15981600
#[meilisearch_test]
15991601
async fn test_reset_typo_tolerance(index: Index) {
16001602
let typo_tolerance = TypoToleranceSettings {
1601-
enabled: false,
1602-
disable_on_attributes: vec![],
1603-
disable_on_words: vec![],
1604-
min_word_size_for_typos: MinWordSizeForTypos {
1603+
enabled: Some(false),
1604+
disable_on_attributes: None,
1605+
disable_on_words: None,
1606+
min_word_size_for_typos: Some(MinWordSizeForTypos {
16051607
one_typo: 1,
16061608
two_typos: 2,
1607-
},
1609+
}),
16081610
};
16091611
let default = TypoToleranceSettings {
1610-
enabled: true,
1611-
disable_on_attributes: vec![],
1612-
disable_on_words: vec![],
1613-
min_word_size_for_typos: MinWordSizeForTypos {
1612+
enabled: Some(true),
1613+
disable_on_attributes: None,
1614+
disable_on_words: None,
1615+
min_word_size_for_typos: Some(MinWordSizeForTypos {
16141616
one_typo: 5,
16151617
two_typos: 9,
1616-
},
1618+
}),
16171619
};
16181620

16191621
let task = index.set_typo_tolerance(&typo_tolerance).await.unwrap();

0 commit comments

Comments
 (0)