@@ -103,6 +103,9 @@ pub struct Settings {
103
103
/// Proximity precision settings.
104
104
#[ serde( skip_serializing_if = "Option::is_none" ) ]
105
105
pub proximity_precision : Option < String > ,
106
+ /// SearchCutoffMs settings.
107
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
108
+ pub search_cutoff_ms : Option < u64 > ,
106
109
}
107
110
108
111
#[ allow( missing_docs) ]
@@ -288,6 +291,13 @@ impl Settings {
288
291
..self
289
292
}
290
293
}
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
+ }
291
301
}
292
302
293
303
impl < Http : HttpClient > Index < Http > {
@@ -757,6 +767,39 @@ impl<Http: HttpClient> Index<Http> {
757
767
. await
758
768
}
759
769
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
+
760
803
/// Update [settings](../settings/struct.Settings) of the [Index].
761
804
///
762
805
/// 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> {
1350
1393
. await
1351
1394
}
1352
1395
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
+
1353
1432
/// Reset [Settings] of the [Index].
1354
1433
///
1355
1434
/// 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> {
1812
1891
)
1813
1892
. await
1814
1893
}
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
+ }
1815
1927
}
1816
1928
1817
1929
#[ cfg( test) ]
@@ -2066,4 +2178,40 @@ mod tests {
2066
2178
2067
2179
assert_eq ! ( expected, default ) ;
2068
2180
}
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
+ }
2069
2217
}
0 commit comments