@@ -13,23 +13,14 @@ pub struct PaginationSetting {
1313 pub max_total_hits : usize ,
1414}
1515
16- #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq , Eq ) ]
16+ #[ derive( Serialize , Deserialize , Default , Debug , Clone , PartialEq , Eq ) ]
1717#[ serde( rename_all = "camelCase" ) ]
1818pub struct MinWordSizeForTypos {
1919 pub one_typo : Option < u8 > ,
2020 pub two_typos : Option < u8 > ,
2121}
2222
23- impl Default for MinWordSizeForTypos {
24- fn default ( ) -> Self {
25- MinWordSizeForTypos {
26- one_typo : Some ( 5 ) ,
27- two_typos : Some ( 9 ) ,
28- }
29- }
30- }
31-
32- #[ derive( Serialize , Deserialize , Debug , Clone , PartialEq , Eq ) ]
23+ #[ derive( Serialize , Deserialize , Default , Debug , Clone , PartialEq , Eq ) ]
3324#[ serde( rename_all = "camelCase" ) ]
3425#[ serde( default ) ]
3526pub struct TypoToleranceSettings {
@@ -39,17 +30,6 @@ pub struct TypoToleranceSettings {
3930 pub min_word_size_for_typos : Option < MinWordSizeForTypos > ,
4031}
4132
42- impl Default for TypoToleranceSettings {
43- fn default ( ) -> Self {
44- TypoToleranceSettings {
45- enabled : Some ( true ) ,
46- disable_on_attributes : Some ( vec ! [ ] ) ,
47- disable_on_words : Some ( vec ! [ ] ) ,
48- min_word_size_for_typos : Some ( MinWordSizeForTypos :: default ( ) ) ,
49- }
50- }
51- }
52-
5333#[ derive( Serialize , Deserialize , Default , Debug , Clone , Eq , PartialEq , Copy ) ]
5434#[ serde( rename_all = "camelCase" ) ]
5535pub struct FacetingSettings {
@@ -123,19 +103,7 @@ pub struct Settings {
123103impl Settings {
124104 /// Create undefined settings.
125105 pub fn new ( ) -> Settings {
126- Settings {
127- synonyms : None ,
128- stop_words : None ,
129- ranking_rules : None ,
130- filterable_attributes : None ,
131- sortable_attributes : None ,
132- distinct_attribute : None ,
133- searchable_attributes : None ,
134- displayed_attributes : None ,
135- pagination : None ,
136- faceting : None ,
137- typo_tolerance : None ,
138- }
106+ Self :: default ( )
139107 }
140108
141109 pub fn with_synonyms < S , U , V > ( self , synonyms : HashMap < S , U > ) -> Settings
@@ -647,7 +615,7 @@ impl Index {
647615 /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
648616 /// #
649617 /// # futures::executor::block_on(async move {
650- /// let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
618+ /// let client = Client::new(MEILISEARCH_HOST, Some( MEILISEARCH_API_KEY) );
651619 /// # client.create_index("get_typo_tolerance", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
652620 /// let index = client.index("get_typo_tolerance");
653621 /// let typotolerance = index.get_typo_tolerance().await.unwrap();
@@ -1133,7 +1101,7 @@ impl Index {
11331101 /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
11341102 /// #
11351103 /// # futures::executor::block_on(async move {
1136- /// let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
1104+ /// let client = Client::new(MEILISEARCH_HOST, Some( MEILISEARCH_API_KEY) );
11371105 /// # client.create_index("set_typo_tolerance", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
11381106 /// let mut index = client.index("set_typo_tolerance");
11391107 ///
@@ -1531,7 +1499,7 @@ impl Index {
15311499 /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
15321500 /// #
15331501 /// # futures::executor::block_on(async move {
1534- /// let client = Client::new(MEILISEARCH_HOST, MEILISEARCH_API_KEY);
1502+ /// let client = Client::new(MEILISEARCH_HOST, Some( MEILISEARCH_API_KEY) );
15351503 /// # client.create_index("reset_typo_tolerance", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
15361504 /// let mut index = client.index("reset_typo_tolerance");
15371505 ///
@@ -1654,37 +1622,61 @@ mod tests {
16541622
16551623 #[ meilisearch_test]
16561624 async fn test_get_typo_tolerance ( index : Index ) {
1657- let typo_tolerance = TypoToleranceSettings :: default ( ) ;
1625+ let expected = TypoToleranceSettings {
1626+ enabled : Some ( true ) ,
1627+ disable_on_attributes : Some ( vec ! [ ] ) ,
1628+ disable_on_words : Some ( vec ! [ ] ) ,
1629+ min_word_size_for_typos : Some ( MinWordSizeForTypos {
1630+ one_typo : Some ( 5 ) ,
1631+ two_typos : Some ( 9 ) ,
1632+ } ) ,
1633+ } ;
16581634
16591635 let res = index. get_typo_tolerance ( ) . await . unwrap ( ) ;
16601636
1661- assert_eq ! ( typo_tolerance , res) ;
1637+ assert_eq ! ( expected , res) ;
16621638 }
16631639
16641640 #[ meilisearch_test]
16651641 async fn test_set_typo_tolerance ( client : Client , index : Index ) {
1666- let typo_tolerance = TypoToleranceSettings {
1642+ let expected = TypoToleranceSettings {
16671643 enabled : Some ( true ) ,
16681644 disable_on_attributes : Some ( vec ! [ "title" . to_string( ) ] ) ,
16691645 disable_on_words : Some ( vec ! [ ] ) ,
1670- min_word_size_for_typos : Some ( MinWordSizeForTypos :: default ( ) ) ,
1646+ min_word_size_for_typos : Some ( MinWordSizeForTypos {
1647+ one_typo : Some ( 5 ) ,
1648+ two_typos : Some ( 9 ) ,
1649+ } ) ,
1650+ } ;
1651+
1652+ let typo_tolerance = TypoToleranceSettings {
1653+ disable_on_attributes : Some ( vec ! [ "title" . to_string( ) ] ) ,
1654+ ..Default :: default ( )
16711655 } ;
16721656
16731657 let task_info = index. set_typo_tolerance ( & typo_tolerance) . await . unwrap ( ) ;
16741658 client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
16751659
16761660 let res = index. get_typo_tolerance ( ) . await . unwrap ( ) ;
16771661
1678- assert_eq ! ( typo_tolerance , res) ;
1662+ assert_eq ! ( expected , res) ;
16791663 }
16801664
16811665 #[ meilisearch_test]
16821666 async fn test_reset_typo_tolerance ( index : Index ) {
1683- let typo_tolerance = TypoToleranceSettings {
1667+ let expected = TypoToleranceSettings {
16841668 enabled : Some ( true ) ,
16851669 disable_on_attributes : Some ( vec ! [ ] ) ,
1686- disable_on_words : Some ( vec ! [ "title" . to_string( ) ] ) ,
1687- min_word_size_for_typos : Some ( MinWordSizeForTypos :: default ( ) ) ,
1670+ disable_on_words : Some ( vec ! [ ] ) ,
1671+ min_word_size_for_typos : Some ( MinWordSizeForTypos {
1672+ one_typo : Some ( 5 ) ,
1673+ two_typos : Some ( 9 ) ,
1674+ } ) ,
1675+ } ;
1676+
1677+ let typo_tolerance = TypoToleranceSettings {
1678+ disable_on_attributes : Some ( vec ! [ "title" . to_string( ) ] ) ,
1679+ ..Default :: default ( )
16881680 } ;
16891681
16901682 let task = index. set_typo_tolerance ( & typo_tolerance) . await . unwrap ( ) ;
@@ -1695,6 +1687,6 @@ mod tests {
16951687
16961688 let default = index. get_typo_tolerance ( ) . await . unwrap ( ) ;
16971689
1698- assert_eq ! ( TypoToleranceSettings :: default ( ) , default ) ;
1690+ assert_eq ! ( expected , default ) ;
16991691 }
17001692}
0 commit comments