@@ -123,17 +123,6 @@ pub struct SearchResults<T> {
123
123
pub index_uid : Option < String > ,
124
124
}
125
125
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
-
137
126
fn serialize_attributes_to_crop_with_wildcard < S : Serializer > (
138
127
data : & Option < Selectors < & [ AttributeToCrop ] > > ,
139
128
s : S ,
@@ -169,6 +158,15 @@ pub enum Selectors<T> {
169
158
All ,
170
159
}
171
160
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
+
172
170
/// Configures Meilisearch to return search results based on a query’s meaning and context
173
171
#[ derive( Debug , Serialize , Clone ) ]
174
172
#[ serde( rename_all = "camelCase" ) ]
@@ -282,7 +280,7 @@ pub struct SearchQuery<'a, Http: HttpClient> {
282
280
pub hits_per_page : Option < usize > ,
283
281
/// Filter applied to documents.
284
282
///
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.
286
284
#[ serde( skip_serializing_if = "Option::is_none" ) ]
287
285
pub filter : Option < Filter < ' a > > ,
288
286
/// Facets for which to retrieve the matching count.
@@ -291,7 +289,6 @@ pub struct SearchQuery<'a, Http: HttpClient> {
291
289
///
292
290
/// **Default: all attributes found in the documents.**
293
291
#[ serde( skip_serializing_if = "Option::is_none" ) ]
294
- #[ serde( serialize_with = "serialize_with_wildcard" ) ]
295
292
pub facets : Option < Selectors < & ' a [ & ' a str ] > > ,
296
293
/// Attributes to sort.
297
294
#[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -309,7 +306,6 @@ pub struct SearchQuery<'a, Http: HttpClient> {
309
306
///
310
307
/// **Default: all attributes found in the documents.**
311
308
#[ serde( skip_serializing_if = "Option::is_none" ) ]
312
- #[ serde( serialize_with = "serialize_with_wildcard" ) ]
313
309
pub attributes_to_retrieve : Option < Selectors < & ' a [ & ' a str ] > > ,
314
310
/// Attributes whose values have to be cropped.
315
311
///
@@ -337,7 +333,6 @@ pub struct SearchQuery<'a, Http: HttpClient> {
337
333
///
338
334
/// Can be set to a [wildcard value](enum.Selectors.html#variant.All) that will select all existing attributes.
339
335
#[ serde( skip_serializing_if = "Option::is_none" ) ]
340
- #[ serde( serialize_with = "serialize_with_wildcard" ) ]
341
336
pub attributes_to_highlight : Option < Selectors < & ' a [ & ' a str ] > > ,
342
337
/// Tag in front of a highlighted term.
343
338
///
@@ -971,7 +966,7 @@ pub struct FacetSearchQuery<'a, Http: HttpClient = DefaultHttpClient> {
971
966
pub search_query : Option < & ' a str > ,
972
967
/// Filter applied to documents.
973
968
///
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.
975
970
#[ serde( skip_serializing_if = "Option::is_none" ) ]
976
971
pub filter : Option < Filter < ' a > > ,
977
972
/// Defines the strategy on how to handle search queries containing multiple words.
@@ -1078,7 +1073,7 @@ pub struct FacetSearchResponse {
1078
1073
}
1079
1074
1080
1075
#[ cfg( test) ]
1081
- mod tests {
1076
+ pub ( crate ) mod tests {
1082
1077
use crate :: {
1083
1078
client:: * ,
1084
1079
key:: { Action , KeyBuilder } ,
@@ -1091,19 +1086,19 @@ mod tests {
1091
1086
use serde_json:: { json, Map , Value } ;
1092
1087
1093
1088
#[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
1094
- struct Nested {
1089
+ pub struct Nested {
1095
1090
child : String ,
1096
1091
}
1097
1092
1098
1093
#[ 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 ,
1105
1100
#[ serde( skip_serializing_if = "Option::is_none" , default ) ]
1106
- _vectors : Option < Vectors > ,
1101
+ pub _vectors : Option < Vectors > ,
1107
1102
}
1108
1103
1109
1104
#[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
@@ -1120,7 +1115,7 @@ mod tests {
1120
1115
}
1121
1116
1122
1117
#[ derive( Debug , Serialize , Deserialize , PartialEq ) ]
1123
- struct Vectors ( HashMap < String , Vector > ) ;
1118
+ pub struct Vectors ( HashMap < String , Vector > ) ;
1124
1119
1125
1120
impl < T : Into < Vec < f32 > > > From < T > for Vectors {
1126
1121
fn from ( value : T ) -> Self {
@@ -1151,7 +1146,7 @@ mod tests {
1151
1146
vector
1152
1147
}
1153
1148
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 > {
1155
1150
let t0 = index. add_documents ( & [
1156
1151
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 ) ) ) } ,
1157
1152
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 {
1225
1220
Ok ( ( ) )
1226
1221
}
1227
1222
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 > {
1229
1224
use crate :: settings:: Embedder ;
1230
1225
let embedder_setting = Embedder {
1231
1226
source : EmbedderSource :: UserProvided ,
@@ -1998,7 +1993,7 @@ mod tests {
1998
1993
1999
1994
#[ meilisearch_test]
2000
1995
async fn test_with_vectors ( client : Client , index : Index ) -> Result < ( ) , Error > {
2001
- setup_hybrid_searching ( & client, & index) . await ?;
1996
+ setup_embedder ( & client, & index) . await ?;
2002
1997
setup_test_index ( & client, & index) . await ?;
2003
1998
2004
1999
let results: SearchResults < Document > = index
@@ -2024,7 +2019,7 @@ mod tests {
2024
2019
2025
2020
#[ meilisearch_test]
2026
2021
async fn test_hybrid ( client : Client , index : Index ) -> Result < ( ) , Error > {
2027
- setup_hybrid_searching ( & client, & index) . await ?;
2022
+ setup_embedder ( & client, & index) . await ?;
2028
2023
setup_test_index ( & client, & index) . await ?;
2029
2024
2030
2025
// Search for an Harry Potter but with lorem ipsum's id
0 commit comments