Skip to content

Commit 72e1bdc

Browse files
committed
Remove Default on HybridSearch
Defaults are set on the backend, not client
1 parent fed5766 commit 72e1bdc

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/search.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,29 +153,17 @@ pub enum Selectors<T> {
153153
All,
154154
}
155155

156-
/// Setting whether to utilise previously defined embedders for semantic searching
156+
/// Configures Meilisearch to return search results based on a query’s meaning and context
157157
#[derive(Debug, Serialize, Clone)]
158158
#[serde(rename_all = "camelCase")]
159159
pub struct HybridSearch<'a> {
160160
/// Indicates one of the embedders configured for the queried index
161-
///
162-
/// **Default: `"default"`**
163161
pub embedder: &'a str,
164162
/// number between `0` and `1`:
165163
/// - `0.0` indicates full keyword search
166164
/// - `1.0` indicates full semantic search
167-
///
168-
/// **Default: `0.5`**
169165
pub semantic_ratio: f32,
170166
}
171-
impl Default for HybridSearch<'_> {
172-
fn default() -> Self {
173-
HybridSearch {
174-
embedder: "default",
175-
semantic_ratio: 0.5,
176-
}
177-
}
178-
}
179167

180168
type AttributeToCrop<'a> = (&'a str, Option<usize>);
181169

@@ -436,6 +424,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
436424
locales: None,
437425
}
438426
}
427+
439428
pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut SearchQuery<'a, Http> {
440429
self.query = Some(query);
441430
self
@@ -445,10 +434,12 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
445434
self.offset = Some(offset);
446435
self
447436
}
437+
448438
pub fn with_limit<'b>(&'b mut self, limit: usize) -> &'b mut SearchQuery<'a, Http> {
449439
self.limit = Some(limit);
450440
self
451441
}
442+
452443
/// Add the page number on which to paginate.
453444
///
454445
/// # Example
@@ -515,17 +506,20 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
515506
self.hits_per_page = Some(hits_per_page);
516507
self
517508
}
509+
518510
pub fn with_filter<'b>(&'b mut self, filter: &'a str) -> &'b mut SearchQuery<'a, Http> {
519511
self.filter = Some(Filter::new(Either::Left(filter)));
520512
self
521513
}
514+
522515
pub fn with_array_filter<'b>(
523516
&'b mut self,
524517
filter: Vec<&'a str>,
525518
) -> &'b mut SearchQuery<'a, Http> {
526519
self.filter = Some(Filter::new(Either::Right(filter)));
527520
self
528521
}
522+
529523
/// Defines whether vectors for semantic searching are returned in the search results
530524
///
531525
/// Can Significantly increase the response size.
@@ -536,13 +530,15 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
536530
self.retrieve_vectors = Some(retrieve_vectors);
537531
self
538532
}
533+
539534
pub fn with_facets<'b>(
540535
&'b mut self,
541536
facets: Selectors<&'a [&'a str]>,
542537
) -> &'b mut SearchQuery<'a, Http> {
543538
self.facets = Some(facets);
544539
self
545540
}
541+
546542
pub fn with_sort<'b>(&'b mut self, sort: &'a [&'a str]) -> &'b mut SearchQuery<'a, Http> {
547543
self.sort = Some(sort);
548544
self
@@ -555,52 +551,60 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
555551
self.attributes_to_search_on = Some(attributes_to_search_on);
556552
self
557553
}
554+
558555
pub fn with_attributes_to_retrieve<'b>(
559556
&'b mut self,
560557
attributes_to_retrieve: Selectors<&'a [&'a str]>,
561558
) -> &'b mut SearchQuery<'a, Http> {
562559
self.attributes_to_retrieve = Some(attributes_to_retrieve);
563560
self
564561
}
562+
565563
pub fn with_attributes_to_crop<'b>(
566564
&'b mut self,
567565
attributes_to_crop: Selectors<&'a [(&'a str, Option<usize>)]>,
568566
) -> &'b mut SearchQuery<'a, Http> {
569567
self.attributes_to_crop = Some(attributes_to_crop);
570568
self
571569
}
570+
572571
pub fn with_crop_length<'b>(&'b mut self, crop_length: usize) -> &'b mut SearchQuery<'a, Http> {
573572
self.crop_length = Some(crop_length);
574573
self
575574
}
575+
576576
pub fn with_crop_marker<'b>(
577577
&'b mut self,
578578
crop_marker: &'a str,
579579
) -> &'b mut SearchQuery<'a, Http> {
580580
self.crop_marker = Some(crop_marker);
581581
self
582582
}
583+
583584
pub fn with_attributes_to_highlight<'b>(
584585
&'b mut self,
585586
attributes_to_highlight: Selectors<&'a [&'a str]>,
586587
) -> &'b mut SearchQuery<'a, Http> {
587588
self.attributes_to_highlight = Some(attributes_to_highlight);
588589
self
589590
}
591+
590592
pub fn with_highlight_pre_tag<'b>(
591593
&'b mut self,
592594
highlight_pre_tag: &'a str,
593595
) -> &'b mut SearchQuery<'a, Http> {
594596
self.highlight_pre_tag = Some(highlight_pre_tag);
595597
self
596598
}
599+
597600
pub fn with_highlight_post_tag<'b>(
598601
&'b mut self,
599602
highlight_post_tag: &'a str,
600603
) -> &'b mut SearchQuery<'a, Http> {
601604
self.highlight_post_tag = Some(highlight_post_tag);
602605
self
603606
}
607+
604608
pub fn with_show_matches_position<'b>(
605609
&'b mut self,
606610
show_matches_position: bool,
@@ -632,10 +636,12 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
632636
self.matching_strategy = Some(matching_strategy);
633637
self
634638
}
639+
635640
pub fn with_index_uid<'b>(&'b mut self) -> &'b mut SearchQuery<'a, Http> {
636641
self.index_uid = Some(&self.index.uid);
637642
self
638643
}
644+
639645
/// Defines whether to utilise previously defined embedders for semantic searching
640646
pub fn with_hybrid<'b>(
641647
&'b mut self,
@@ -648,29 +654,35 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
648654
});
649655
self
650656
}
657+
651658
/// Defines what vectors an userprovided embedder has gotten for semantic searching
652659
pub fn with_vector<'b>(&'b mut self, vector: &'a [f32]) -> &'b mut SearchQuery<'a, Http> {
653660
self.vector = Some(vector);
654661
self
655662
}
663+
656664
pub fn with_distinct<'b>(&'b mut self, distinct: &'a str) -> &'b mut SearchQuery<'a, Http> {
657665
self.distinct = Some(distinct);
658666
self
659667
}
668+
660669
pub fn with_ranking_score_threshold<'b>(
661670
&'b mut self,
662671
ranking_score_threshold: f64,
663672
) -> &'b mut SearchQuery<'a, Http> {
664673
self.ranking_score_threshold = Some(ranking_score_threshold);
665674
self
666675
}
676+
667677
pub fn with_locales<'b>(&'b mut self, locales: &'a [&'a str]) -> &'b mut SearchQuery<'a, Http> {
668678
self.locales = Some(locales);
669679
self
670680
}
681+
671682
pub fn build(&mut self) -> SearchQuery<'a, Http> {
672683
self.clone()
673684
}
685+
674686
/// Execute the query and fetch the results.
675687
pub async fn execute<T: 'static + DeserializeOwned + Send + Sync>(
676688
&'a self,

0 commit comments

Comments
 (0)