1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::query::QueryTrait;
use serde_json::{json, Value};
use crate::util::UtilMap;

#[derive(Default)]
pub struct MatchAllQuery {
    boost: Option<f64>,
}


impl MatchAllQuery {
    pub fn new() -> MatchAllQuery {
        let mut query = MatchAllQuery::default();
        return query;
    }
    pub fn set_boost(mut self, boost: f64) -> MatchAllQuery {
        self.boost = Some(boost);
        self
    }
}

impl QueryTrait for MatchAllQuery {
    fn build(&self) -> Value {

        let mut root = UtilMap::new();
        root.append_boost(self.boost);
        root.build_object(self.query_name())
    }

    fn query_name(&self) -> String {
        return "match_all".to_string();
    }
}
#[test]
fn test() {
    let build = MatchAllQuery::new().set_boost(100.0);
    assert_eq!("{\"match_all\":{\"boost\":100.0}}", build.build().to_string());
    let build = MatchAllQuery::new();
    assert_eq!("{\"match_all\":{}}", build.build().to_string());
}