@@ -123,17 +123,6 @@ pub struct SearchResults<T> {
123123 pub index_uid : Option < String > ,
124124}
125125
126- fn serialize_with_wildcard < S : Serializer , T : Serialize > (
127- data : & Option < Selectors < T > > ,
128- s : S ,
129- ) -> Result < S :: Ok , S :: Error > {
130- match data {
131- Some ( Selectors :: All ) => [ "*" ] . serialize ( s) ,
132- Some ( Selectors :: Some ( data) ) => data. serialize ( s) ,
133- None => s. serialize_none ( ) ,
134- }
135- }
136-
137126fn serialize_attributes_to_crop_with_wildcard < S : Serializer > (
138127 data : & Option < Selectors < & [ AttributeToCrop ] > > ,
139128 s : S ,
@@ -169,6 +158,15 @@ pub enum Selectors<T> {
169158 All ,
170159}
171160
161+ impl < T : Serialize > Serialize for Selectors < T > {
162+ fn serialize < S : Serializer > ( & self , s : S ) -> Result < S :: Ok , S :: Error > {
163+ match self {
164+ Selectors :: Some ( data) => data. serialize ( s) ,
165+ Selectors :: All => [ "*" ] . serialize ( s) ,
166+ }
167+ }
168+ }
169+
172170/// Configures Meilisearch to return search results based on a query’s meaning and context
173171#[ derive( Debug , Serialize , Clone ) ]
174172#[ serde( rename_all = "camelCase" ) ]
@@ -282,7 +280,7 @@ pub struct SearchQuery<'a, Http: HttpClient> {
282280 pub hits_per_page : Option < usize > ,
283281 /// Filter applied to documents.
284282 ///
285- /// Read the [dedicated guide](https://www.meilisearch.com/docs/learn/advanced/filtering ) to learn the syntax.
283+ /// Read the [dedicated guide](https://www.meilisearch.com/docs/learn/filtering_and_sorting ) to learn the syntax.
286284 #[ serde( skip_serializing_if = "Option::is_none" ) ]
287285 pub filter : Option < Filter < ' a > > ,
288286 /// Facets for which to retrieve the matching count.
@@ -291,7 +289,6 @@ pub struct SearchQuery<'a, Http: HttpClient> {
291289 ///
292290 /// **Default: all attributes found in the documents.**
293291 #[ serde( skip_serializing_if = "Option::is_none" ) ]
294- #[ serde( serialize_with = "serialize_with_wildcard" ) ]
295292 pub facets : Option < Selectors < & ' a [ & ' a str ] > > ,
296293 /// Attributes to sort.
297294 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -309,7 +306,6 @@ pub struct SearchQuery<'a, Http: HttpClient> {
309306 ///
310307 /// **Default: all attributes found in the documents.**
311308 #[ serde( skip_serializing_if = "Option::is_none" ) ]
312- #[ serde( serialize_with = "serialize_with_wildcard" ) ]
313309 pub attributes_to_retrieve : Option < Selectors < & ' a [ & ' a str ] > > ,
314310 /// Attributes whose values have to be cropped.
315311 ///
@@ -337,7 +333,6 @@ pub struct SearchQuery<'a, Http: HttpClient> {
337333 ///
338334 /// Can be set to a [wildcard value](enum.Selectors.html#variant.All) that will select all existing attributes.
339335 #[ serde( skip_serializing_if = "Option::is_none" ) ]
340- #[ serde( serialize_with = "serialize_with_wildcard" ) ]
341336 pub attributes_to_highlight : Option < Selectors < & ' a [ & ' a str ] > > ,
342337 /// Tag in front of a highlighted term.
343338 ///
@@ -971,7 +966,7 @@ pub struct FacetSearchQuery<'a, Http: HttpClient = DefaultHttpClient> {
971966 pub search_query : Option < & ' a str > ,
972967 /// Filter applied to documents.
973968 ///
974- /// Read the [dedicated guide](https://www.meilisearch.com/docs/learn/advanced/filtering ) to learn the syntax.
969+ /// Read the [dedicated guide](https://www.meilisearch.com/docs/learn/filtering_and_sorting ) to learn the syntax.
975970 #[ serde( skip_serializing_if = "Option::is_none" ) ]
976971 pub filter : Option < Filter < ' a > > ,
977972 /// Defines the strategy on how to handle search queries containing multiple words.
@@ -1078,7 +1073,7 @@ pub struct FacetSearchResponse {
10781073}
10791074
10801075#[ cfg( test) ]
1081- mod tests {
1076+ pub ( crate ) mod tests {
10821077 use crate :: {
10831078 client:: * ,
10841079 key:: { Action , KeyBuilder } ,
@@ -1091,19 +1086,19 @@ mod tests {
10911086 use serde_json:: { json, Map , Value } ;
10921087
10931088 #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
1094- struct Nested {
1089+ pub struct Nested {
10951090 child : String ,
10961091 }
10971092
10981093 #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
1099- struct Document {
1100- id : usize ,
1101- value : String ,
1102- kind : String ,
1103- number : i32 ,
1104- nested : Nested ,
1094+ pub struct Document {
1095+ pub id : usize ,
1096+ pub value : String ,
1097+ pub kind : String ,
1098+ pub number : i32 ,
1099+ pub nested : Nested ,
11051100 #[ serde( skip_serializing_if = "Option::is_none" , default ) ]
1106- _vectors : Option < Vectors > ,
1101+ pub _vectors : Option < Vectors > ,
11071102 }
11081103
11091104 #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
@@ -1120,7 +1115,7 @@ mod tests {
11201115 }
11211116
11221117 #[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
1123- struct Vectors ( HashMap < String , Vector > ) ;
1118+ pub struct Vectors ( HashMap < String , Vector > ) ;
11241119
11251120 impl < T : Into < Vec < f32 > > > From < T > for Vectors {
11261121 fn from ( value : T ) -> Self {
@@ -1151,7 +1146,7 @@ mod tests {
11511146 vector
11521147 }
11531148
1154- async fn setup_test_index ( client : & Client , index : & Index ) -> Result < ( ) , Error > {
1149+ pub ( crate ) async fn setup_test_index ( client : & Client , index : & Index ) -> Result < ( ) , Error > {
11551150 let t0 = index. add_documents ( & [
11561151 Document { id : 0 , kind : "text" . into ( ) , number : 0 , value : S ( "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." ) , nested : Nested { child : S ( "first" ) } , _vectors : Some ( Vectors :: from ( vectorize ( false , 0 ) ) ) } ,
11571152 Document { id : 1 , kind : "text" . into ( ) , number : 10 , value : S ( "dolor sit amet, consectetur adipiscing elit" ) , nested : Nested { child : S ( "second" ) } , _vectors : Some ( Vectors :: from ( vectorize ( false , 1 ) ) ) } ,
@@ -1225,7 +1220,7 @@ mod tests {
12251220 Ok ( ( ) )
12261221 }
12271222
1228- async fn setup_hybrid_searching ( client : & Client , index : & Index ) -> Result < ( ) , Error > {
1223+ pub ( crate ) async fn setup_embedder ( client : & Client , index : & Index ) -> Result < ( ) , Error > {
12291224 use crate :: settings:: Embedder ;
12301225 let embedder_setting = Embedder {
12311226 source : EmbedderSource :: UserProvided ,
@@ -1998,7 +1993,7 @@ mod tests {
19981993
19991994 #[ meilisearch_test]
20001995 async fn test_with_vectors ( client : Client , index : Index ) -> Result < ( ) , Error > {
2001- setup_hybrid_searching ( & client, & index) . await ?;
1996+ setup_embedder ( & client, & index) . await ?;
20021997 setup_test_index ( & client, & index) . await ?;
20031998
20041999 let results: SearchResults < Document > = index
@@ -2024,7 +2019,7 @@ mod tests {
20242019
20252020 #[ meilisearch_test]
20262021 async fn test_hybrid ( client : Client , index : Index ) -> Result < ( ) , Error > {
2027- setup_hybrid_searching ( & client, & index) . await ?;
2022+ setup_embedder ( & client, & index) . await ?;
20282023 setup_test_index ( & client, & index) . await ?;
20292024
20302025 // Search for an Harry Potter but with lorem ipsum's id
0 commit comments