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
mod max_aggregation;
mod min_aggregation;
mod sum_aggregation;
mod terms_aggregation;
mod top_hits_aggregation;

use crate::aggregation::max_aggregation::MaxAggregation;
use crate::aggregation::min_aggregation::MinAggregation;
use crate::aggregation::sum_aggregation::SumAggregation;
use crate::aggregation::terms_aggregation::TermsAggregation;
use crate::aggregation::top_hits_aggregation::TopHitsAggregation;
use serde_json::Value;

pub trait AggregationTrait {
    fn name(&self) -> &str;
    fn build(&self) -> Value;
    fn query_name(&self) -> String;
}

pub struct Aggregation {}

impl Aggregation {
    pub fn terms(name: &str) -> TermsAggregation {
        TermsAggregation::new(name)
    }
    pub fn top_hits(name: &str) -> TopHitsAggregation {
        TopHitsAggregation::new(name)
    }
    pub fn sum(name: &str) -> SumAggregation {
        SumAggregation::new(name)
    }
    pub fn max(name: &str) -> MaxAggregation {
        MaxAggregation::new(name)
    }
    pub fn min(name: &str) -> MinAggregation {
        MinAggregation::new(name)
    }
}