@@ -95,6 +95,9 @@ pub struct Settings {
9595 /// TypoTolerance settings
9696 #[ serde( skip_serializing_if = "Option::is_none" ) ]
9797 pub typo_tolerance : Option < TypoToleranceSettings > ,
98+ /// Dictionary settings.
99+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
100+ pub dictionary : Option < Vec < String > > ,
98101}
99102
100103#[ allow( missing_docs) ]
@@ -243,6 +246,21 @@ impl Settings {
243246 ..self
244247 }
245248 }
249+
250+ pub fn with_dictionary (
251+ self ,
252+ dictionary : impl IntoIterator < Item = impl AsRef < str > > ,
253+ ) -> Settings {
254+ Settings {
255+ dictionary : Some (
256+ dictionary
257+ . into_iter ( )
258+ . map ( |v| v. as_ref ( ) . to_string ( ) )
259+ . collect ( ) ,
260+ ) ,
261+ ..self
262+ }
263+ }
246264}
247265
248266impl Index {
@@ -604,6 +622,38 @@ impl Index {
604622 . await
605623 }
606624
625+ /// Get [dictionary](https://www.meilisearch.com/docs/reference/api/settings#dictionary) of the [Index].
626+ ///
627+ /// # Example
628+ ///
629+ /// ```
630+ /// # use meilisearch_sdk::{client::*, indexes::*};
631+ /// #
632+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
633+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
634+ /// #
635+ /// # futures::executor::block_on(async move {
636+ /// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY));
637+ /// # client.create_index("get_dictionary", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
638+ /// let index = client.index("get_dictionary");
639+ ///
640+ /// let dictionary = index.get_dictionary().await.unwrap();
641+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
642+ /// # });
643+ /// ```
644+ pub async fn get_dictionary ( & self ) -> Result < Vec < String > , Error > {
645+ request :: < ( ) , ( ) , Vec < String > > (
646+ & format ! (
647+ "{}/indexes/{}/settings/dictionary" ,
648+ self . client. host, self . uid
649+ ) ,
650+ self . client . get_api_key ( ) ,
651+ Method :: Get { query : ( ) } ,
652+ 200 ,
653+ )
654+ . await
655+ }
656+
607657 /// Get [typo tolerance](https://www.meilisearch.com/docs/learn/configuration/typo_tolerance#typo-tolerance) of the [Index].
608658 ///
609659 /// ```
@@ -1089,6 +1139,47 @@ impl Index {
10891139 . await
10901140 }
10911141
1142+ /// Update [dictionary](https://www.meilisearch.com/docs/reference/api/settings#dictionary) of the [Index].
1143+ ///
1144+ /// # Example
1145+ ///
1146+ /// ```
1147+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
1148+ /// #
1149+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
1150+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
1151+ /// #
1152+ /// # futures::executor::block_on(async move {
1153+ /// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY));
1154+ /// # client.create_index("set_dictionary", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1155+ /// let mut index = client.index("set_dictionary");
1156+ ///
1157+ /// let task = index.set_dictionary(["J. K.", "J. R. R."]).await.unwrap();
1158+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1159+ /// # });
1160+ /// ```
1161+ pub async fn set_dictionary (
1162+ & self ,
1163+ dictionary : impl IntoIterator < Item = impl AsRef < str > > ,
1164+ ) -> Result < TaskInfo , Error > {
1165+ request :: < ( ) , Vec < String > , TaskInfo > (
1166+ & format ! (
1167+ "{}/indexes/{}/settings/dictionary" ,
1168+ self . client. host, self . uid
1169+ ) ,
1170+ self . client . get_api_key ( ) ,
1171+ Method :: Put {
1172+ query : ( ) ,
1173+ body : dictionary
1174+ . into_iter ( )
1175+ . map ( |v| v. as_ref ( ) . to_string ( ) )
1176+ . collect ( ) ,
1177+ } ,
1178+ 202 ,
1179+ )
1180+ . await
1181+ }
1182+
10921183 /// Update [typo tolerance](https://www.meilisearch.com/docs/learn/configuration/typo_tolerance#typo-tolerance) settings of the [Index].
10931184 ///
10941185 /// # Example
@@ -1487,6 +1578,38 @@ impl Index {
14871578 . await
14881579 }
14891580
1581+ /// Reset [dictionary](https://www.meilisearch.com/docs/reference/api/settings#dictionary) of the [Index].
1582+ ///
1583+ /// # Example
1584+ ///
1585+ /// ```
1586+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
1587+ /// #
1588+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
1589+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
1590+ /// #
1591+ /// # futures::executor::block_on(async move {
1592+ /// # let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY));
1593+ /// # client.create_index("reset_dictionary", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1594+ /// let mut index = client.index("reset_dictionary");
1595+ ///
1596+ /// let task = index.reset_dictionary().await.unwrap();
1597+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1598+ /// # });
1599+ /// ```
1600+ pub async fn reset_dictionary ( & self ) -> Result < TaskInfo , Error > {
1601+ request :: < ( ) , ( ) , TaskInfo > (
1602+ & format ! (
1603+ "{}/indexes/{}/settings/dictionary" ,
1604+ self . client. host, self . uid
1605+ ) ,
1606+ self . client . get_api_key ( ) ,
1607+ Method :: Delete { query : ( ) } ,
1608+ 202 ,
1609+ )
1610+ . await
1611+ }
1612+
14901613 /// Reset [typo tolerance](https://www.meilisearch.com/docs/learn/configuration/typo_tolerance#typo-tolerance) settings of the [Index].
14911614 ///
14921615 /// # Example
@@ -1579,6 +1702,48 @@ mod tests {
15791702 assert_eq ! ( faceting, res) ;
15801703 }
15811704
1705+ #[ meilisearch_test]
1706+ async fn test_get_dicitonary ( index : Index ) {
1707+ let dictionary: Vec < String > = vec ! [ ] ;
1708+
1709+ let res = index. get_dictionary ( ) . await . unwrap ( ) ;
1710+
1711+ assert_eq ! ( dictionary, res) ;
1712+ }
1713+
1714+ #[ meilisearch_test]
1715+ async fn test_set_dicitonary ( client : Client , index : Index ) {
1716+ let dictionary: Vec < & str > = vec ! [ "J. K." , "J. R. R." ] ;
1717+ let task_info = index. set_dictionary ( & dictionary) . await . unwrap ( ) ;
1718+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
1719+
1720+ let res = index. get_dictionary ( ) . await . unwrap ( ) ;
1721+
1722+ assert_eq ! ( dictionary, res) ;
1723+ }
1724+
1725+ #[ meilisearch_test]
1726+ async fn test_set_empty_dicitonary ( client : Client , index : Index ) {
1727+ let dictionary: Vec < & str > = vec ! [ ] ;
1728+ let task_info = index. set_dictionary ( & dictionary) . await . unwrap ( ) ;
1729+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
1730+
1731+ let res = index. get_dictionary ( ) . await . unwrap ( ) ;
1732+
1733+ assert_eq ! ( dictionary, res) ;
1734+ }
1735+
1736+ #[ meilisearch_test]
1737+ async fn test_reset_dictionary ( client : Client , index : Index ) {
1738+ let dictionary: Vec < & str > = vec ! [ ] ;
1739+ let task_info = index. reset_dictionary ( ) . await . unwrap ( ) ;
1740+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
1741+
1742+ let res = index. get_dictionary ( ) . await . unwrap ( ) ;
1743+
1744+ assert_eq ! ( dictionary, res) ;
1745+ }
1746+
15821747 #[ meilisearch_test]
15831748 async fn test_get_pagination ( index : Index ) {
15841749 let pagination = PaginationSetting {
0 commit comments