os_query_builder_rs/compound_query/
disjunction_max.rs1use serde::Serialize;
2use crate::misc::query_field::QueryField;
3
4#[derive(Debug, Clone, Serialize)]
5pub struct DisMax {
6 queries: Vec<QueryField>,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 tie_breaker: Option<f64>
9}
10
11
12impl DisMax {
13
14 pub fn new<T, F>(queries: F) -> Self
15 where T: Into<QueryField>,
16 F: IntoIterator<Item=T>
17 {
18 Self {
19 queries: queries.into_iter().map(|x|x.into()).collect(),
20 tie_breaker: None
21 }
22 }
23
24 pub fn tie_breaker<T: Into<f64>>(self, tie_breaker: T) -> Self {
25 Self {
26 tie_breaker: Some(tie_breaker.into()),
27 ..self
28 }
29 }
30}