Newer
Older
<?php
/*
* This file is part of the ONGR package.
*
* (c) NFQ Technologies UAB <info@nfq.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ONGR\ElasticsearchDSL\Filter;
@trigger_error(
'The AndFilter class is deprecated and will be removed in 2.0. Use BoolQuery instead.',
E_USER_DEPRECATED
);
use ONGR\ElasticsearchDSL\BuilderInterface;
use ONGR\ElasticsearchDSL\ParametersTrait;
*
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
*
* @deprecated Will be removed in 2.0. Use the BoolQuery instead.
*/
class AndFilter implements BuilderInterface
{
use ParametersTrait;
/**
* @param BuilderInterface[] $filters Filter array.
public function __construct(array $filters = [], array $parameters = [])
* Sets filters.
*
* @param BuilderInterface[] $filters Filter array.
foreach ($filters as $filter) {
$this->add($filter);
}
}
/**
* Adds filter.
*
* @param BuilderInterface $filter
*
* @return AndFilter
*/
public function add(BuilderInterface $filter)
{
$this->filters[] = [$filter->getType() => $filter->toArray()];
return $this;
}
/**
* Clears filters.
*/
public function clear()
{
$this->filters = [];
}
/**
* {@inheritdoc}
*/
public function toArray()
{
if (count($query) > 0) {
$query['filters'] = $this->filters;
} else {
$query = $this->filters;
/**
* {@inheritdoc}
*/
public function getType()
{
return 'and';