@@ -106,6 +106,12 @@ pub struct Settings {
106106 /// SearchCutoffMs settings.
107107 #[ serde( skip_serializing_if = "Option::is_none" ) ]
108108 pub search_cutoff_ms : Option < u64 > ,
109+ /// Configure strings as custom separator tokens indicating where a word ends and begins.
110+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
111+ pub separator_tokens : Option < Vec < String > > ,
112+ /// Remove tokens from Meilisearch's default [list of word separators](https://www.meilisearch.com/docs/learn/engine/datatypes#string).
113+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
114+ pub non_separator_tokens : Option < Vec < String > > ,
109115}
110116
111117#[ allow( missing_docs) ]
@@ -298,6 +304,38 @@ impl Settings {
298304 ..self
299305 }
300306 }
307+
308+ #[ must_use]
309+ pub fn with_separation_tokens (
310+ self ,
311+ separator_tokens : impl IntoIterator < Item = impl AsRef < str > > ,
312+ ) -> Settings {
313+ Settings {
314+ separator_tokens : Some (
315+ separator_tokens
316+ . into_iter ( )
317+ . map ( |v| v. as_ref ( ) . to_string ( ) )
318+ . collect ( ) ,
319+ ) ,
320+ ..self
321+ }
322+ }
323+
324+ #[ must_use]
325+ pub fn with_non_separation_tokens (
326+ self ,
327+ non_separator_tokens : impl IntoIterator < Item = impl AsRef < str > > ,
328+ ) -> Settings {
329+ Settings {
330+ non_separator_tokens : Some (
331+ non_separator_tokens
332+ . into_iter ( )
333+ . map ( |v| v. as_ref ( ) . to_string ( ) )
334+ . collect ( ) ,
335+ ) ,
336+ ..self
337+ }
338+ }
301339}
302340
303341impl < Http : HttpClient > Index < Http > {
@@ -799,6 +837,67 @@ impl<Http: HttpClient> Index<Http> {
799837 )
800838 . await
801839 }
840+ /// Get [separator token](https://www.meilisearch.com/docs/reference/api/settings#separator-tokens) of the [Index].
841+ ///
842+ /// ```
843+ /// # use meilisearch_sdk::{client::*, indexes::*};
844+ /// # client.create_index("get_separator_tokens", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
845+ /// #
846+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
847+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
848+ /// #
849+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
850+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
851+ /// let index = client.index("get_separator_tokens");
852+ ///
853+ /// let separator_tokens = index.get_separator_tokens().await.unwrap();
854+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
855+ /// # });
856+ /// ```
857+ pub async fn get_separator_tokens ( & self ) -> Result < Vec < String > , Error > {
858+ self . client
859+ . http_client
860+ . request :: < ( ) , ( ) , Vec < String > > (
861+ & format ! (
862+ "{}/indexes/{}/settings/separator-tokens" ,
863+ self . client. host, self . uid
864+ ) ,
865+ Method :: Get { query : ( ) } ,
866+ 200 ,
867+ )
868+ . await
869+ }
870+
871+ /// Get [non separator token](https://www.meilisearch.com/docs/reference/api/settings#non-separator-tokens) of the [Index].
872+ ///
873+ /// ```
874+ /// # use meilisearch_sdk::{client::*, indexes::*};
875+ /// #
876+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
877+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
878+ /// #
879+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
880+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
881+ /// # client.create_index("get_non_separator_tokens", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
882+ /// let index = client.index("get_non_separator_tokens");
883+ ///
884+ /// let non_separator_tokens = index.get_non_separator_tokens().await.unwrap();
885+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
886+ /// # });
887+ /// ```
888+ pub async fn get_non_separator_tokens ( & self ) -> Result < Vec < String > , Error > {
889+ self . client
890+ . http_client
891+ . request :: < ( ) , ( ) , Vec < String > > (
892+ & format ! (
893+ "{}/indexes/{}/settings/non-separator-tokens" ,
894+ self . client. host, self . uid
895+ ) ,
896+ Method :: Get { query : ( ) } ,
897+ 200 ,
898+ )
899+ . await
900+ }
802901
803902 /// Update [settings](../settings/struct.Settings) of the [Index].
804903 ///
@@ -1354,6 +1453,88 @@ impl<Http: HttpClient> Index<Http> {
13541453 . await
13551454 }
13561455
1456+ /// Update [separator tokens](https://www.meilisearch.com/docs/reference/api/settings#separator-tokens) settings of the [Index].
1457+ ///
1458+ /// # Example
1459+ ///
1460+ /// ```
1461+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings, settings::{TypoToleranceSettings, MinWordSizeForTypos}};
1462+ /// #
1463+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
1464+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
1465+ /// #
1466+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
1467+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
1468+ /// # client.create_index("set_separator_tokens", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1469+ /// let mut index = client.index("set_separator_tokens");
1470+ ///
1471+ /// let separator_token: Vec<String> = vec!["@".to_string(), "#".to_string()];
1472+ ///
1473+ /// let task = index.set_separator_tokens(&separator_token).await.unwrap();
1474+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1475+ /// # });
1476+ /// ```
1477+ pub async fn set_separator_tokens (
1478+ & self ,
1479+ separator_token : & Vec < String > ,
1480+ ) -> Result < TaskInfo , Error > {
1481+ self . client
1482+ . http_client
1483+ . request :: < ( ) , & Vec < String > , TaskInfo > (
1484+ & format ! (
1485+ "{}/indexes/{}/settings/separator-tokens" ,
1486+ self . client. host, self . uid
1487+ ) ,
1488+ Method :: Put {
1489+ query : ( ) ,
1490+ body : separator_token,
1491+ } ,
1492+ 202 ,
1493+ )
1494+ . await
1495+ }
1496+
1497+ /// Update [non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#non-separator-tokens) settings of the [Index].
1498+ ///
1499+ /// # Example
1500+ ///
1501+ /// ```
1502+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings, settings::{TypoToleranceSettings, MinWordSizeForTypos}};
1503+ /// #
1504+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
1505+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
1506+ /// #
1507+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
1508+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
1509+ /// # client.create_index("set_non_separator_tokens", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1510+ /// let mut index = client.index("set_non_separator_tokens");
1511+ ///
1512+ /// let non_separator_token: Vec<String> = vec!["@".to_string(), "#".to_string()];
1513+ ///
1514+ /// let task = index.set_non_separator_tokens(&non_separator_token).await.unwrap();
1515+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1516+ /// # });
1517+ /// ```
1518+ pub async fn set_non_separator_tokens (
1519+ & self ,
1520+ non_separator_token : & Vec < String > ,
1521+ ) -> Result < TaskInfo , Error > {
1522+ self . client
1523+ . http_client
1524+ . request :: < ( ) , & Vec < String > , TaskInfo > (
1525+ & format ! (
1526+ "{}/indexes/{}/settings/non-separator-tokens" ,
1527+ self . client. host, self . uid
1528+ ) ,
1529+ Method :: Put {
1530+ query : ( ) ,
1531+ body : non_separator_token,
1532+ } ,
1533+ 202 ,
1534+ )
1535+ . await
1536+ }
1537+
13571538 /// Update [proximity-precision](https://www.meilisearch.com/docs/learn/configuration/proximity-precision) settings of the [Index].
13581539 ///
13591540 /// # Example
@@ -1892,7 +2073,7 @@ impl<Http: HttpClient> Index<Http> {
18922073 . await
18932074 }
18942075
1895- /// Reset [search cutoff ](https://www.meilisearch.com/docs/reference/api/settings#search-cutoff) settings of the [Index].
2076+ /// Reset [proximity precision ](https://www.meilisearch.com/docs/reference/api/settings#
18962077 ///
18972078 /// # Example
18982079 ///
@@ -1924,6 +2105,72 @@ impl<Http: HttpClient> Index<Http> {
19242105 )
19252106 . await
19262107 }
2108+
2109+ /// Reset [search cutoff](https://www.meilisearch.com/docs/reference/api/settings#search-cutoff) settings of the [Index].
2110+ ///
2111+ /// # Example
2112+ ///
2113+ /// ```
2114+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
2115+ /// #
2116+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
2117+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
2118+ /// #
2119+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
2120+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
2121+ /// # client.create_index("reset_separator_tokens", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
2122+ /// let mut index = client.index("reset_separator_tokens");
2123+ ///
2124+ /// let task = index.reset_separator_tokens().await.unwrap();
2125+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
2126+ /// # });
2127+ /// ```
2128+ pub async fn reset_separator_tokens ( & self ) -> Result < TaskInfo , Error > {
2129+ self . client
2130+ . http_client
2131+ . request :: < ( ) , ( ) , TaskInfo > (
2132+ & format ! (
2133+ "{}/indexes/{}/settings/separator-tokens" ,
2134+ self . client. host, self . uid
2135+ ) ,
2136+ Method :: Delete { query : ( ) } ,
2137+ 202 ,
2138+ )
2139+ . await
2140+ }
2141+
2142+ /// Reset [non separator tokens](https://www.meilisearch.com/docs/reference/api/settings#non-separator-tokens) settings of the [Index].
2143+ ///
2144+ /// # Example
2145+ ///
2146+ /// ```
2147+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
2148+ /// #
2149+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
2150+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
2151+ /// #
2152+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
2153+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
2154+ /// # client.create_index("reset_non_separator_tokens", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
2155+ /// let mut index = client.index("reset_non_separator_tokens");
2156+ ///
2157+ /// let task = index.reset_non_separator_tokens().await.unwrap();
2158+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
2159+ /// # });
2160+ /// ```
2161+ pub async fn reset_non_separator_tokens ( & self ) -> Result < TaskInfo , Error > {
2162+ self . client
2163+ . http_client
2164+ . request :: < ( ) , ( ) , TaskInfo > (
2165+ & format ! (
2166+ "{}/indexes/{}/settings/non-separator-tokens" ,
2167+ self . client. host, self . uid
2168+ ) ,
2169+ Method :: Delete { query : ( ) } ,
2170+ 202 ,
2171+ )
2172+ . await
2173+ }
19272174}
19282175
19292176#[ cfg( test) ]
@@ -2200,6 +2447,28 @@ mod tests {
22002447 assert_eq ! ( expected, res) ;
22012448 }
22022449
2450+ async fn test_get_separator_tokens ( index : Index ) {
2451+ let separator: Vec < & str > = vec ! [ ] ;
2452+ let res = index. get_separator_tokens ( ) . await . unwrap ( ) ;
2453+
2454+ assert_eq ! ( separator, res) ;
2455+ }
2456+
2457+ #[ meilisearch_test]
2458+ async fn test_set_separator_tokens ( client : Client , index : Index ) {
2459+ let expected: Vec < String > = vec ! [ "@" . to_string( ) , "#" . to_string( ) ] ;
2460+
2461+ let task_info = index
2462+ . set_separator_tokens ( & expected)
2463+ . await
2464+ . unwrap ( ) ;
2465+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
2466+
2467+ let mut res = index. get_separator_tokens ( ) . await . unwrap ( ) ;
2468+
2469+ assert_eq ! ( expected, res) ;
2470+ }
2471+
22032472 #[ meilisearch_test]
22042473 async fn test_reset_search_cutoff_ms ( index : Index ) {
22052474 let expected = None ;
@@ -2214,4 +2483,47 @@ mod tests {
22142483
22152484 assert_eq ! ( expected, default ) ;
22162485 }
2486+
2487+ #[ meilisearch_test]
2488+ async fn test_reset_separator_tokens ( client : Client , index : Index ) {
2489+ let separator: Vec < & str > = vec ! [ ] ;
2490+ let task_info = index. reset_separator_tokens ( ) . await . unwrap ( ) ;
2491+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
2492+
2493+ let res = index. get_dictionary ( ) . await . unwrap ( ) ;
2494+ assert_eq ! ( separator, res) ;
2495+ }
2496+
2497+ #[ meilisearch_test]
2498+ async fn test_get_non_separator_tokens ( index : Index ) {
2499+ let separator: Vec < & str > = vec ! [ ] ;
2500+ let res = index. get_non_separator_tokens ( ) . await . unwrap ( ) ;
2501+
2502+ assert_eq ! ( separator, res) ;
2503+ }
2504+
2505+ #[ meilisearch_test]
2506+ async fn test_set_non_separator_tokens ( client : Client , index : Index ) {
2507+ let expected: Vec < String > = vec ! [ "@" . to_string( ) , "#" . to_string( ) ] ;
2508+
2509+ let task_info = index
2510+ . set_non_separator_tokens ( & expected)
2511+ . await
2512+ . unwrap ( ) ;
2513+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
2514+
2515+ let mut res = index. get_non_separator_tokens ( ) . await . unwrap ( ) ;
2516+
2517+ assert_eq ! ( expected, res) ;
2518+ }
2519+
2520+ #[ meilisearch_test]
2521+ async fn test_reset_non_separator_tokens ( client : Client , index : Index ) {
2522+ let separator: Vec < & str > = vec ! [ ] ;
2523+ let task_info = index. reset_non_separator_tokens ( ) . await . unwrap ( ) ;
2524+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
2525+
2526+ let res = index. get_dictionary ( ) . await . unwrap ( ) ;
2527+ assert_eq ! ( separator, res) ;
2528+ }
22172529}
0 commit comments