1111use Ensi \LaravelElasticQuery \Aggregating \CompositeAggregationBuilder ;
1212use Ensi \LaravelElasticQuery \Aggregating \FiltersCollection ;
1313use Ensi \LaravelElasticQuery \Aggregating \Metrics \CardinalityAggregation ;
14+ use Ensi \LaravelElasticQuery \Aggregating \Metrics \MaxAggregation ;
15+ use Ensi \LaravelElasticQuery \Aggregating \Metrics \MinAggregation ;
1416use Ensi \LaravelElasticQuery \Aggregating \Metrics \MinMaxAggregation ;
1517use Ensi \LaravelElasticQuery \Aggregating \Metrics \ValueCountAggregation ;
1618use Ensi \LaravelElasticQuery \Contracts \Aggregation ;
1719use Ensi \LaravelElasticQuery \Contracts \Criteria ;
1820use Ensi \LaravelElasticQuery \Filtering \BoolQueryBuilder ;
1921use Ensi \LaravelElasticQuery \Search \Sorting \Sort ;
22+ use Ensi \LaravelElasticQuery \Search \Sorting \SortCollection ;
2023
2124trait ConstructsAggregations
2225{
@@ -30,8 +33,8 @@ public function terms(
3033 string $ name ,
3134 string $ field ,
3235 ?int $ size = null ,
33- ? Sort $ sort = null ,
34- ? Aggregation $ composite = null ,
36+ Sort | SortCollection | null $ sort = null ,
37+ Aggregation | AggregationCollection | null $ composite = null ,
3538 ): static {
3639 $ this ->aggregations ->add (new TermsAggregation ($ name , $ this ->absolutePath ($ field ), $ size , $ sort , $ composite ));
3740
@@ -48,7 +51,7 @@ public function filter(string $name, Criteria $criteria, AggregationCollection $
4851 public function filters (
4952 string $ name ,
5053 FiltersCollection $ filters ,
51- ? Aggregation $ composite = null ,
54+ Aggregation | AggregationCollection | null $ composite = null ,
5255 ?string $ otherBucketKey = null ,
5356 ): static {
5457 $ this ->aggregations ->add (new FiltersAggregation ($ name , $ filters , $ composite , $ otherBucketKey ));
@@ -63,6 +66,20 @@ public function minmax(string $name, string $field): static
6366 return $ this ;
6467 }
6568
69+ public function min (string $ name , string $ field , mixed $ missing = null ): static
70+ {
71+ $ this ->aggregations ->add (new MinAggregation ($ name , $ this ->absolutePath ($ field ), $ missing ));
72+
73+ return $ this ;
74+ }
75+
76+ public function max (string $ name , string $ field , mixed $ missing = null ): static
77+ {
78+ $ this ->aggregations ->add (new MaxAggregation ($ name , $ this ->absolutePath ($ field ), $ missing ));
79+
80+ return $ this ;
81+ }
82+
6683 public function count (string $ name , string $ field ): static
6784 {
6885 $ this ->aggregations ->add (new ValueCountAggregation ($ name , $ this ->absolutePath ($ field )));
0 commit comments