@@ -103,6 +103,9 @@ pub struct Settings {
103103 /// Proximity precision settings.
104104 #[ serde( skip_serializing_if = "Option::is_none" ) ]
105105 pub proximity_precision : Option < String > ,
106+ /// SearchCutoffMs settings.
107+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
108+ pub search_cutoff_ms : Option < u64 > ,
106109}
107110
108111#[ allow( missing_docs) ]
@@ -288,6 +291,13 @@ impl Settings {
288291 ..self
289292 }
290293 }
294+
295+ pub fn with_search_cutoff ( self , search_cutoff_ms : u64 ) -> Settings {
296+ Settings {
297+ search_cutoff_ms : Some ( search_cutoff_ms) ,
298+ ..self
299+ }
300+ }
291301}
292302
293303impl < Http : HttpClient > Index < Http > {
@@ -757,6 +767,39 @@ impl<Http: HttpClient> Index<Http> {
757767 . await
758768 }
759769
770+ /// Get [search cutoff](https://www.meilisearch.com/docs/reference/api/settings#search-cutoff) settings of the [Index].
771+ ///
772+ /// # Example
773+ ///
774+ /// ```
775+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
776+ /// #
777+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
778+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
779+ /// #
780+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
781+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
782+ /// # client.create_index("get_search_cutoff_ms", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
783+ /// let mut index = client.index("get_search_cutoff_ms");
784+ ///
785+ /// let task = index.get_search_cutoff_ms().await.unwrap();
786+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
787+ /// # });
788+ /// ```
789+ pub async fn get_search_cutoff_ms ( & self ) -> Result < Option < u64 > , Error > {
790+ self . client
791+ . http_client
792+ . request :: < ( ) , ( ) , Option < u64 > > (
793+ & format ! (
794+ "{}/indexes/{}/settings/search-cutoff-ms" ,
795+ self . client. host, self . uid
796+ ) ,
797+ Method :: Get { query : ( ) } ,
798+ 200 ,
799+ )
800+ . await
801+ }
802+
760803 /// Update [settings](../settings/struct.Settings) of the [Index].
761804 ///
762805 /// Updates in the settings are partial. This means that any parameters corresponding to a `None` value will be left unchanged.
@@ -1350,6 +1393,42 @@ impl<Http: HttpClient> Index<Http> {
13501393 . await
13511394 }
13521395
1396+ /// Update [search cutoff](https://www.meilisearch.com/docs/reference/api/settings#search-cutoff) settings of the [Index].
1397+ ///
1398+ /// # Example
1399+ ///
1400+ /// ```
1401+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
1402+ /// #
1403+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
1404+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
1405+ /// #
1406+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
1407+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
1408+ /// # client.create_index("update_search_cutoff_ms", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1409+ /// let mut index = client.index("update_search_cutoff_ms");
1410+ ///
1411+ /// let task = index.set_search_cutoff_ms(Some(150)).await.unwrap();
1412+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1413+ /// # });
1414+ /// ```
1415+ pub async fn set_search_cutoff_ms ( & self , ms : Option < u64 > ) -> Result < TaskInfo , Error > {
1416+ self . client
1417+ . http_client
1418+ . request :: < ( ) , Option < u64 > , TaskInfo > (
1419+ & format ! (
1420+ "{}/indexes/{}/settings/search-cutoff-ms" ,
1421+ self . client. host, self . uid
1422+ ) ,
1423+ Method :: Put {
1424+ body : ms,
1425+ query : ( ) ,
1426+ } ,
1427+ 202 ,
1428+ )
1429+ . await
1430+ }
1431+
13531432 /// Reset [Settings] of the [Index].
13541433 ///
13551434 /// All settings will be reset to their [default value](https://www.meilisearch.com/docs/reference/api/settings#reset-settings).
@@ -1812,6 +1891,39 @@ impl<Http: HttpClient> Index<Http> {
18121891 )
18131892 . await
18141893 }
1894+
1895+ /// Reset [search cutoff](https://www.meilisearch.com/docs/reference/api/settings#search-cutoff) settings of the [Index].
1896+ ///
1897+ /// # Example
1898+ ///
1899+ /// ```
1900+ /// # use meilisearch_sdk::{client::*, indexes::*, settings::Settings};
1901+ /// #
1902+ /// # let MEILISEARCH_URL = option_env!("MEILISEARCH_URL").unwrap_or("http://localhost:7700");
1903+ /// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
1904+ /// #
1905+ /// # tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {
1906+ /// let client = Client::new(MEILISEARCH_URL, Some(MEILISEARCH_API_KEY)).unwrap();
1907+ /// # client.create_index("reset_search_cutoff_ms", None).await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1908+ /// let mut index = client.index("reset_search_cutoff_ms");
1909+ ///
1910+ /// let task = index.reset_search_cutoff_ms().await.unwrap();
1911+ /// # index.delete().await.unwrap().wait_for_completion(&client, None, None).await.unwrap();
1912+ /// # });
1913+ /// ```
1914+ pub async fn reset_search_cutoff_ms ( & self ) -> Result < TaskInfo , Error > {
1915+ self . client
1916+ . http_client
1917+ . request :: < ( ) , ( ) , TaskInfo > (
1918+ & format ! (
1919+ "{}/indexes/{}/settings/search-cutoff-ms" ,
1920+ self . client. host, self . uid
1921+ ) ,
1922+ Method :: Delete { query : ( ) } ,
1923+ 202 ,
1924+ )
1925+ . await
1926+ }
18151927}
18161928
18171929#[ cfg( test) ]
@@ -2066,4 +2178,40 @@ mod tests {
20662178
20672179 assert_eq ! ( expected, default ) ;
20682180 }
2181+
2182+ #[ meilisearch_test]
2183+ async fn test_get_search_cutoff_ms ( index : Index ) {
2184+ let expected = None ;
2185+
2186+ let res = index. get_search_cutoff_ms ( ) . await . unwrap ( ) ;
2187+
2188+ assert_eq ! ( expected, res) ;
2189+ }
2190+
2191+ #[ meilisearch_test]
2192+ async fn test_set_search_cutoff_ms ( client : Client , index : Index ) {
2193+ let expected = Some ( 150 ) ;
2194+
2195+ let task_info = index. set_search_cutoff_ms ( Some ( 150 ) ) . await . unwrap ( ) ;
2196+ client. wait_for_task ( task_info, None , None ) . await . unwrap ( ) ;
2197+
2198+ let res = index. get_search_cutoff_ms ( ) . await . unwrap ( ) ;
2199+
2200+ assert_eq ! ( expected, res) ;
2201+ }
2202+
2203+ #[ meilisearch_test]
2204+ async fn test_reset_search_cutoff_ms ( index : Index ) {
2205+ let expected = None ;
2206+
2207+ let task = index. set_search_cutoff_ms ( Some ( 150 ) ) . await . unwrap ( ) ;
2208+ index. wait_for_task ( task, None , None ) . await . unwrap ( ) ;
2209+
2210+ let reset_task = index. reset_search_cutoff_ms ( ) . await . unwrap ( ) ;
2211+ index. wait_for_task ( reset_task, None , None ) . await . unwrap ( ) ;
2212+
2213+ let default = index. get_search_cutoff_ms ( ) . await . unwrap ( ) ;
2214+
2215+ assert_eq ! ( expected, default ) ;
2216+ }
20692217}
0 commit comments