@@ -78,7 +78,7 @@ fn serialize_attributes_to_crop_with_wildcard<S: Serializer>(
78
78
}
79
79
}
80
80
81
- /// Some list fields in a `Query ` can be set to a wildcard value.
81
+ /// Some list fields in a `SearchQuery ` can be set to a wildcard value.
82
82
/// This structure allows you to choose between the wildcard value and an exhaustive list of selectors.
83
83
#[ derive( Debug , Clone ) ]
84
84
pub enum Selectors < T > {
@@ -98,7 +98,7 @@ type AttributeToCrop<'a> = (&'a str, Option<usize>);
98
98
///
99
99
/// ```
100
100
/// use serde::{Serialize, Deserialize};
101
- /// # use meilisearch_sdk::{client::Client, search::Query , indexes::Index};
101
+ /// # use meilisearch_sdk::{client::Client, search::SearchQuery , indexes::Index};
102
102
/// #
103
103
/// # let MEILISEARCH_HOST = option_env!("MEILISEARCH_HOST").unwrap_or("http://localhost:7700");
104
104
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
@@ -120,7 +120,7 @@ type AttributeToCrop<'a> = (&'a str, Option<usize>);
120
120
/// # .try_make_index(&client)
121
121
/// # .unwrap();
122
122
///
123
- /// let mut res = Query ::new(&index)
123
+ /// let mut res = SearchQuery ::new(&index)
124
124
/// .with_query("space")
125
125
/// .with_offset(42)
126
126
/// .with_limit(21)
@@ -134,7 +134,7 @@ type AttributeToCrop<'a> = (&'a str, Option<usize>);
134
134
/// ```
135
135
///
136
136
/// ```
137
- /// # use meilisearch_sdk::{client::Client, search::Query , indexes::Index};
137
+ /// # use meilisearch_sdk::{client::Client, search::SearchQuery , indexes::Index};
138
138
/// #
139
139
/// # let MEILISEARCH_HOST = option_env!("MEILISEARCH_HOST").unwrap_or("http://localhost:7700");
140
140
/// # let MEILISEARCH_API_KEY = option_env!("MEILISEARCH_API_KEY").unwrap_or("masterKey");
@@ -149,7 +149,7 @@ type AttributeToCrop<'a> = (&'a str, Option<usize>);
149
149
/// ```
150
150
#[ derive( Debug , Serialize , Clone ) ]
151
151
#[ serde( rename_all = "camelCase" ) ]
152
- pub struct Query < ' a > {
152
+ pub struct SearchQuery < ' a > {
153
153
#[ serde( skip_serializing) ]
154
154
index : & ' a Index ,
155
155
/// The text that will be searched for among the documents.
@@ -237,9 +237,9 @@ pub struct Query<'a> {
237
237
}
238
238
239
239
#[ allow( missing_docs) ]
240
- impl < ' a > Query < ' a > {
241
- pub fn new ( index : & ' a Index ) -> Query < ' a > {
242
- Query {
240
+ impl < ' a > SearchQuery < ' a > {
241
+ pub fn new ( index : & ' a Index ) -> SearchQuery < ' a > {
242
+ SearchQuery {
243
243
index,
244
244
query : None ,
245
245
offset : None ,
@@ -257,82 +257,82 @@ impl<'a> Query<'a> {
257
257
show_matches_position : None ,
258
258
}
259
259
}
260
- pub fn with_query < ' b > ( & ' b mut self , query : & ' a str ) -> & ' b mut Query < ' a > {
260
+ pub fn with_query < ' b > ( & ' b mut self , query : & ' a str ) -> & ' b mut SearchQuery < ' a > {
261
261
self . query = Some ( query) ;
262
262
self
263
263
}
264
264
265
- pub fn with_offset < ' b > ( & ' b mut self , offset : usize ) -> & ' b mut Query < ' a > {
265
+ pub fn with_offset < ' b > ( & ' b mut self , offset : usize ) -> & ' b mut SearchQuery < ' a > {
266
266
self . offset = Some ( offset) ;
267
267
self
268
268
}
269
- pub fn with_limit < ' b > ( & ' b mut self , limit : usize ) -> & ' b mut Query < ' a > {
269
+ pub fn with_limit < ' b > ( & ' b mut self , limit : usize ) -> & ' b mut SearchQuery < ' a > {
270
270
self . limit = Some ( limit) ;
271
271
self
272
272
}
273
- pub fn with_filter < ' b > ( & ' b mut self , filter : & ' a str ) -> & ' b mut Query < ' a > {
273
+ pub fn with_filter < ' b > ( & ' b mut self , filter : & ' a str ) -> & ' b mut SearchQuery < ' a > {
274
274
self . filter = Some ( filter) ;
275
275
self
276
276
}
277
- pub fn with_facets < ' b > ( & ' b mut self , facets : Selectors < & ' a [ & ' a str ] > ) -> & ' b mut Query < ' a > {
277
+ pub fn with_facets < ' b > ( & ' b mut self , facets : Selectors < & ' a [ & ' a str ] > ) -> & ' b mut SearchQuery < ' a > {
278
278
self . facets = Some ( facets) ;
279
279
self
280
280
}
281
- pub fn with_sort < ' b > ( & ' b mut self , sort : & ' a [ & ' a str ] ) -> & ' b mut Query < ' a > {
281
+ pub fn with_sort < ' b > ( & ' b mut self , sort : & ' a [ & ' a str ] ) -> & ' b mut SearchQuery < ' a > {
282
282
self . sort = Some ( sort) ;
283
283
self
284
284
}
285
285
pub fn with_attributes_to_retrieve < ' b > (
286
286
& ' b mut self ,
287
287
attributes_to_retrieve : Selectors < & ' a [ & ' a str ] > ,
288
- ) -> & ' b mut Query < ' a > {
288
+ ) -> & ' b mut SearchQuery < ' a > {
289
289
self . attributes_to_retrieve = Some ( attributes_to_retrieve) ;
290
290
self
291
291
}
292
292
pub fn with_attributes_to_crop < ' b > (
293
293
& ' b mut self ,
294
294
attributes_to_crop : Selectors < & ' a [ ( & ' a str , Option < usize > ) ] > ,
295
- ) -> & ' b mut Query < ' a > {
295
+ ) -> & ' b mut SearchQuery < ' a > {
296
296
self . attributes_to_crop = Some ( attributes_to_crop) ;
297
297
self
298
298
}
299
- pub fn with_crop_length < ' b > ( & ' b mut self , crop_length : usize ) -> & ' b mut Query < ' a > {
299
+ pub fn with_crop_length < ' b > ( & ' b mut self , crop_length : usize ) -> & ' b mut SearchQuery < ' a > {
300
300
self . crop_length = Some ( crop_length) ;
301
301
self
302
302
}
303
- pub fn with_crop_marker < ' b > ( & ' b mut self , crop_marker : & ' a str ) -> & ' b mut Query < ' a > {
303
+ pub fn with_crop_marker < ' b > ( & ' b mut self , crop_marker : & ' a str ) -> & ' b mut SearchQuery < ' a > {
304
304
self . crop_marker = Some ( crop_marker) ;
305
305
self
306
306
}
307
307
pub fn with_attributes_to_highlight < ' b > (
308
308
& ' b mut self ,
309
309
attributes_to_highlight : Selectors < & ' a [ & ' a str ] > ,
310
- ) -> & ' b mut Query < ' a > {
310
+ ) -> & ' b mut SearchQuery < ' a > {
311
311
self . attributes_to_highlight = Some ( attributes_to_highlight) ;
312
312
self
313
313
}
314
314
pub fn with_highlight_pre_tag < ' b > (
315
315
& ' b mut self ,
316
316
highlight_pre_tag : & ' a str ,
317
- ) -> & ' b mut Query < ' a > {
317
+ ) -> & ' b mut SearchQuery < ' a > {
318
318
self . highlight_pre_tag = Some ( highlight_pre_tag) ;
319
319
self
320
320
}
321
321
pub fn with_highlight_post_tag < ' b > (
322
322
& ' b mut self ,
323
323
highlight_post_tag : & ' a str ,
324
- ) -> & ' b mut Query < ' a > {
324
+ ) -> & ' b mut SearchQuery < ' a > {
325
325
self . highlight_post_tag = Some ( highlight_post_tag) ;
326
326
self
327
327
}
328
328
pub fn with_show_matches_position < ' b > (
329
329
& ' b mut self ,
330
330
show_matches_position : bool ,
331
- ) -> & ' b mut Query < ' a > {
331
+ ) -> & ' b mut SearchQuery < ' a > {
332
332
self . show_matches_position = Some ( show_matches_position) ;
333
333
self
334
334
}
335
- pub fn build ( & mut self ) -> Query < ' a > {
335
+ pub fn build ( & mut self ) -> SearchQuery < ' a > {
336
336
self . clone ( )
337
337
}
338
338
@@ -397,7 +397,7 @@ mod tests {
397
397
398
398
#[ meilisearch_test]
399
399
async fn test_query_builder ( _client : Client , index : Index ) -> Result < ( ) , Error > {
400
- let mut query = Query :: new ( & index) ;
400
+ let mut query = SearchQuery :: new ( & index) ;
401
401
query. with_query ( "space" ) . with_offset ( 42 ) . with_limit ( 21 ) ;
402
402
403
403
let res = query. execute :: < Document > ( ) . await . unwrap ( ) ;
@@ -481,7 +481,7 @@ mod tests {
481
481
async fn test_query_facet_distribution ( client : Client , index : Index ) -> Result < ( ) , Error > {
482
482
setup_test_index ( & client, & index) . await ?;
483
483
484
- let mut query = Query :: new ( & index) ;
484
+ let mut query = SearchQuery :: new ( & index) ;
485
485
query. with_facets ( Selectors :: All ) ;
486
486
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
487
487
assert_eq ! (
@@ -495,7 +495,7 @@ mod tests {
495
495
& 8
496
496
) ;
497
497
498
- let mut query = Query :: new ( & index) ;
498
+ let mut query = SearchQuery :: new ( & index) ;
499
499
query. with_facets ( Selectors :: Some ( & [ "kind" ] ) ) ;
500
500
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
501
501
assert_eq ! (
@@ -533,7 +533,7 @@ mod tests {
533
533
. await ?;
534
534
assert_eq ! ( results. hits. len( ) , 10 ) ;
535
535
536
- let mut query = Query :: new ( & index) ;
536
+ let mut query = SearchQuery :: new ( & index) ;
537
537
query. with_attributes_to_retrieve ( Selectors :: Some ( & [ "kind" , "id" ] ) ) ; // omit the "value" field
538
538
assert ! ( index. execute_query:: <Document >( & query) . await . is_err( ) ) ; // error: missing "value" field
539
539
Ok ( ( ) )
@@ -543,7 +543,7 @@ mod tests {
543
543
async fn test_query_sort ( client : Client , index : Index ) -> Result < ( ) , Error > {
544
544
setup_test_index ( & client, & index) . await ?;
545
545
546
- let mut query = Query :: new ( & index) ;
546
+ let mut query = SearchQuery :: new ( & index) ;
547
547
query. with_query ( "harry potter" ) ;
548
548
query. with_sort ( & [ "title:desc" ] ) ;
549
549
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
@@ -555,7 +555,7 @@ mod tests {
555
555
async fn test_query_attributes_to_crop ( client : Client , index : Index ) -> Result < ( ) , Error > {
556
556
setup_test_index ( & client, & index) . await ?;
557
557
558
- let mut query = Query :: new ( & index) ;
558
+ let mut query = SearchQuery :: new ( & index) ;
559
559
query. with_query ( "lorem ipsum" ) ;
560
560
query. with_attributes_to_crop ( Selectors :: All ) ;
561
561
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
@@ -572,7 +572,7 @@ mod tests {
572
572
results. hits[ 0 ] . formatted_result. as_ref( ) . unwrap( )
573
573
) ;
574
574
575
- let mut query = Query :: new ( & index) ;
575
+ let mut query = SearchQuery :: new ( & index) ;
576
576
query. with_query ( "lorem ipsum" ) ;
577
577
query. with_attributes_to_crop ( Selectors :: Some ( & [ ( "value" , Some ( 5 ) ) , ( "kind" , None ) ] ) ) ;
578
578
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
@@ -594,7 +594,7 @@ mod tests {
594
594
async fn test_query_crop_length ( client : Client , index : Index ) -> Result < ( ) , Error > {
595
595
setup_test_index ( & client, & index) . await ?;
596
596
597
- let mut query = Query :: new ( & index) ;
597
+ let mut query = SearchQuery :: new ( & index) ;
598
598
query. with_query ( "lorem ipsum" ) ;
599
599
query. with_attributes_to_crop ( Selectors :: All ) ;
600
600
query. with_crop_length ( 200 ) ;
@@ -607,7 +607,7 @@ mod tests {
607
607
} ,
608
608
results. hits[ 0 ] . formatted_result. as_ref( ) . unwrap( ) ) ;
609
609
610
- let mut query = Query :: new ( & index) ;
610
+ let mut query = SearchQuery :: new ( & index) ;
611
611
query. with_query ( "lorem ipsum" ) ;
612
612
query. with_attributes_to_crop ( Selectors :: All ) ;
613
613
query. with_crop_length ( 5 ) ;
@@ -630,7 +630,7 @@ mod tests {
630
630
async fn test_query_customized_crop_marker ( client : Client , index : Index ) -> Result < ( ) , Error > {
631
631
setup_test_index ( & client, & index) . await ?;
632
632
633
- let mut query = Query :: new ( & index) ;
633
+ let mut query = SearchQuery :: new ( & index) ;
634
634
query. with_query ( "sed do eiusmod" ) ;
635
635
query. with_attributes_to_crop ( Selectors :: All ) ;
636
636
query. with_crop_length ( 6 ) ;
@@ -659,7 +659,7 @@ mod tests {
659
659
) -> Result < ( ) , Error > {
660
660
setup_test_index ( & client, & index) . await ?;
661
661
662
- let mut query = Query :: new ( & index) ;
662
+ let mut query = SearchQuery :: new ( & index) ;
663
663
query. with_query ( "Social" ) ;
664
664
query. with_attributes_to_highlight ( Selectors :: All ) ;
665
665
query. with_highlight_pre_tag ( "(⊃。•́‿•̀。)⊃ " ) ;
@@ -685,7 +685,7 @@ mod tests {
685
685
async fn test_query_attributes_to_highlight ( client : Client , index : Index ) -> Result < ( ) , Error > {
686
686
setup_test_index ( & client, & index) . await ?;
687
687
688
- let mut query = Query :: new ( & index) ;
688
+ let mut query = SearchQuery :: new ( & index) ;
689
689
query. with_query ( "dolor text" ) ;
690
690
query. with_attributes_to_highlight ( Selectors :: All ) ;
691
691
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
@@ -701,7 +701,7 @@ mod tests {
701
701
results. hits[ 0 ] . formatted_result. as_ref( ) . unwrap( ) ,
702
702
) ;
703
703
704
- let mut query = Query :: new ( & index) ;
704
+ let mut query = SearchQuery :: new ( & index) ;
705
705
query. with_query ( "dolor text" ) ;
706
706
query. with_attributes_to_highlight ( Selectors :: Some ( & [ "value" ] ) ) ;
707
707
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
@@ -723,7 +723,7 @@ mod tests {
723
723
async fn test_query_show_matches_position ( client : Client , index : Index ) -> Result < ( ) , Error > {
724
724
setup_test_index ( & client, & index) . await ?;
725
725
726
- let mut query = Query :: new ( & index) ;
726
+ let mut query = SearchQuery :: new ( & index) ;
727
727
query. with_query ( "dolor text" ) ;
728
728
query. with_show_matches_position ( true ) ;
729
729
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
@@ -747,7 +747,7 @@ mod tests {
747
747
async fn test_phrase_search ( client : Client , index : Index ) -> Result < ( ) , Error > {
748
748
setup_test_index ( & client, & index) . await ?;
749
749
750
- let mut query = Query :: new ( & index) ;
750
+ let mut query = SearchQuery :: new ( & index) ;
751
751
query. with_query ( "harry \" of Fire\" " ) ;
752
752
let results: SearchResults < Document > = index. execute_query ( & query) . await ?;
753
753
0 commit comments