Skip to content

Commit 4051890

Browse files
Add federation_options to SearchQuery
1 parent 8a5f558 commit 4051890

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/search.rs

+19
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,16 @@ pub struct SearchQuery<'a, Http: HttpClient> {
353353

354354
#[serde(skip_serializing_if = "Option::is_none")]
355355
pub(crate) index_uid: Option<&'a str>,
356+
357+
#[serde(skip_serializing_if = "Option::is_none")]
358+
pub(crate) federation_options: Option<QueryFederationOptions>,
359+
}
360+
361+
#[derive(Debug, Serialize, Clone)]
362+
#[serde(rename_all = "camelCase")]
363+
pub struct QueryFederationOptions {
364+
#[serde(skip_serializing_if = "Option::is_none")]
365+
pub weight: Option<f32>,
356366
}
357367

358368
#[allow(missing_docs)]
@@ -385,6 +395,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
385395
distinct: None,
386396
ranking_score_threshold: None,
387397
locales: None,
398+
federation_options: None,
388399
}
389400
}
390401
pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut SearchQuery<'a, Http> {
@@ -592,6 +603,14 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
592603
self.locales = Some(locales);
593604
self
594605
}
606+
/// Only usable in federated multi search queries.
607+
pub fn with_federation_options<'b>(
608+
&'b mut self,
609+
federation_options: QueryFederationOptions,
610+
) -> &'b mut SearchQuery<'a, Http> {
611+
self.federation_options = Some(federation_options);
612+
self
613+
}
595614
pub fn build(&mut self) -> SearchQuery<'a, Http> {
596615
self.clone()
597616
}

0 commit comments

Comments
 (0)