@@ -344,6 +344,10 @@ pub struct SearchQuery<'a, Http: HttpClient> {
344344 #[ serde( skip_serializing_if = "Option::is_none" ) ]
345345 pub ranking_score_threshold : Option < f64 > ,
346346
347+ /// Defines the language of the search query.
348+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
349+ pub locales : Option < & ' a [ & ' a str ] > ,
350+
347351 #[ serde( skip_serializing_if = "Option::is_none" ) ]
348352 pub ( crate ) index_uid : Option < & ' a str > ,
349353}
@@ -377,6 +381,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
377381 index_uid : None ,
378382 distinct : None ,
379383 ranking_score_threshold : None ,
384+ locales : None ,
380385 }
381386 }
382387 pub fn with_query < ' b > ( & ' b mut self , query : & ' a str ) -> & ' b mut SearchQuery < ' a , Http > {
@@ -580,6 +585,10 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
580585 self . ranking_score_threshold = Some ( ranking_score_threshold) ;
581586 self
582587 }
588+ pub fn with_locales < ' b > ( & ' b mut self , locales : & ' a [ & ' a str ] ) -> & ' b mut SearchQuery < ' a , Http > {
589+ self . locales = Some ( locales) ;
590+ self
591+ }
583592 pub fn build ( & mut self ) -> SearchQuery < ' a , Http > {
584593 self . clone ( )
585594 }
@@ -1161,6 +1170,18 @@ mod tests {
11611170 Ok ( ( ) )
11621171 }
11631172
1173+ #[ meilisearch_test]
1174+ async fn test_query_locales ( client : Client , index : Index ) -> Result < ( ) , Error > {
1175+ setup_test_index ( & client, & index) . await ?;
1176+
1177+ let mut query = SearchQuery :: new ( & index) ;
1178+ query. with_query ( "Harry Styles" ) ;
1179+ query. with_locales ( & [ "eng" ] ) ;
1180+ let results: SearchResults < Document > = index. execute_query ( & query) . await . unwrap ( ) ;
1181+ assert_eq ! ( results. hits. len( ) , 7 ) ;
1182+ Ok ( ( ) )
1183+ }
1184+
11641185 #[ meilisearch_test]
11651186 async fn test_phrase_search ( client : Client , index : Index ) -> Result < ( ) , Error > {
11661187 setup_test_index ( & client, & index) . await ?;
0 commit comments