Skip to content

Commit f0e0b6f

Browse files
authored
Merge pull request #48 from ensi-platform/filter-aggs
Filter aggregations
2 parents 7972f85 + 4d60870 commit f0e0b6f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Concerns/ConstructsAggregations.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
use Closure;
66
use Ensi\LaravelElasticQuery\Aggregating\AggregationCollection;
7+
use Ensi\LaravelElasticQuery\Aggregating\Bucket\FilterAggregation;
78
use Ensi\LaravelElasticQuery\Aggregating\Bucket\NestedAggregation;
89
use Ensi\LaravelElasticQuery\Aggregating\Bucket\TermsAggregation;
910
use Ensi\LaravelElasticQuery\Aggregating\CompositeAggregationBuilder;
1011
use Ensi\LaravelElasticQuery\Aggregating\Metrics\MinMaxAggregation;
1112
use Ensi\LaravelElasticQuery\Aggregating\Metrics\ValueCountAggregation;
1213
use Ensi\LaravelElasticQuery\Contracts\Aggregation;
14+
use Ensi\LaravelElasticQuery\Contracts\Criteria;
1315
use Ensi\LaravelElasticQuery\Filtering\BoolQueryBuilder;
1416
use Ensi\LaravelElasticQuery\Search\Sorting\Sort;
1517

@@ -33,6 +35,13 @@ public function terms(
3335
return $this;
3436
}
3537

38+
public function filter(string $name, Criteria $criteria, AggregationCollection $children): static
39+
{
40+
$this->aggregations->add(new FilterAggregation($name, $criteria, $children));
41+
42+
return $this;
43+
}
44+
3645
public function minmax(string $name, string $field): static
3746
{
3847
$this->aggregations->add(new MinMaxAggregation($name, $this->absolutePath($field)));

0 commit comments

Comments
 (0)