Skip to content

Commit

Permalink
Add federation_options to SearchQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Dec 16, 2024
1 parent 08291fa commit 406d8ca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ pub struct SearchQuery<'a, Http: HttpClient> {

#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) index_uid: Option<&'a str>,

#[serde(skip_serializing_if = "Option::is_none")]
pub(crate) federation_options: Option<QueryFederationOptions>,
}

#[derive(Debug, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct QueryFederationOptions {
#[serde(skip_serializing_if = "Option::is_none")]
pub weight: Option<f32>,
}

#[allow(missing_docs)]
Expand Down Expand Up @@ -380,6 +390,7 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
index_uid: None,
distinct: None,
ranking_score_threshold: None,
federation_options: None,
}
}
pub fn with_query<'b>(&'b mut self, query: &'a str) -> &'b mut SearchQuery<'a, Http> {
Expand Down Expand Up @@ -583,6 +594,14 @@ impl<'a, Http: HttpClient> SearchQuery<'a, Http> {
self.ranking_score_threshold = Some(ranking_score_threshold);
self
}
/// Only usable in federated multi search queries.
pub fn with_federation_options<'b>(
&'b mut self,
federation_options: QueryFederationOptions,
) -> &'b mut SearchQuery<'a, Http> {
self.federation_options = Some(federation_options);
self
}
pub fn build(&mut self) -> SearchQuery<'a, Http> {
self.clone()
}
Expand Down

0 comments on commit 406d8ca

Please sign in to comment.