for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchBundle\DSL\Aggregation;
use ONGR\ElasticsearchBundle\DSL\Aggregation\Type\BucketingTrait;
use ONGR\ElasticsearchBundle\DSL\BuilderInterface;
/**
* Class representing filters aggregation.
class FiltersAggregation extends AbstractAggregation
{
use BucketingTrait;
* @var BuilderInterface[]
private $filters = [];
* @var bool
private $anonymous = false;
* @param bool $anonymous
* @return FiltersAggregation
public function setAnonymous($anonymous)
$this->anonymous = $anonymous;
return $this;
}
* @param BuilderInterface $filter
* @param string $name
* @throws \LogicException
public function addFilter(BuilderInterface $filter, $name = '')
if ($this->anonymous === false && empty($name)) {
throw new \LogicException('In not anonymous filters filter name must be set.');
} elseif ($this->anonymous === false && !empty($name)) {
$this->filters['filters'][$name] = [$filter->getType() => $filter->toArray()];
} else {
$this->filters['filters'][] = [$filter->getType() => $filter->toArray()];
* {@inheritdoc}
public function getArray()
return $this->filters;
public function getType()
return 'filters';