os_query_builder_rs/compound_query/
boosting.rs

1use serde::Serialize;
2use crate::misc::query_field::QueryField;
3
4#[derive(Debug, Clone, Serialize)]
5pub struct Boosting {
6    positive: Box<QueryField>,
7    negative: Box<QueryField>,
8    #[serde(skip_serializing_if = "Option::is_none")]
9    negative_boost: Option<f64>
10}
11
12impl Boosting {
13
14    pub fn new<T,F>(positive: T, negative: F) -> Self
15        where T: Into<QueryField>,
16              F: Into<QueryField>
17    {
18        Self {
19            positive: Box::new(positive.into()),
20            negative: Box::new(negative.into()),
21            negative_boost: None
22        }
23    }
24
25    pub fn negative_boost<T: Into<f64>>(self, negative_boost: T) -> Self {
26        Self {
27            negative_boost: Some(negative_boost.into()),
28            ..self
29        }
30    }
31}