os_query_builder_rs/compound_query/
constant_score.rs1use serde::Serialize;
2use crate::misc::query_field::QueryField;
3
4#[derive(Debug, Clone, Serialize)]
5pub struct ConstantScore {
6 filter: Box<QueryField>,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 boost: Option<f64>
9}
10
11impl ConstantScore {
12 pub fn new<T:Into<QueryField>>(filter: T) -> Self {
13 Self {
14 filter: Box::new(filter.into()),
15 boost: None
16 }
17 }
18
19 pub fn boost<T: Into<f64>>(self, boost: T) -> Self {
20 Self {
21 boost: Some(boost.into()),
22 ..self
23 }
24 }
25}