Skip to content

Commit

Permalink
Remove filters from Elastica as filers are removed in ES 5.0
Browse files Browse the repository at this point in the history
* Remove outdated QueryBuilder. Update 2.4 query builder to only use queries
* Remove deprecated Script*.php classes

Part of #1184
  • Loading branch information
ruflin committed Oct 12, 2016
1 parent 65b245b commit e5786fa
Show file tree
Hide file tree
Showing 114 changed files with 61 additions and 8,708 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file based on the
- Composer installations will no longer include tests and other development files.
- Replace flush refresh param with a options array
- Rename Mapping::setFields to Mapping::setStoredFields
- Removing all deprecated filters including tests. Use queries instead.
- Remove deprecated Elastica\Script*.php classes. Use Elastica\Script\* instead.

### Bugfixes

Expand Down
17 changes: 2 additions & 15 deletions lib/Elastica/Aggregation/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
use Elastica\Filter\AbstractFilter;
use Elastica\Query\AbstractQuery;

/**
Expand All @@ -16,17 +15,11 @@ class Filter extends AbstractAggregation
* @param string $name
* @param AbstractQuery $filter
*/
public function __construct($name, $filter = null)
public function __construct($name, AbstractQuery $filter = null)
{
parent::__construct($name);

if ($filter !== null) {
if ($filter instanceof AbstractFilter) {
trigger_error('Deprecated: Elastica\Aggregation\Filter passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', E_USER_DEPRECATED);
} elseif (!($filter instanceof AbstractQuery)) {
throw new InvalidException('Filter must be instance of AbstractQuery');
}

$this->setFilter($filter);
}
}
Expand All @@ -38,14 +31,8 @@ public function __construct($name, $filter = null)
*
* @return $this
*/
public function setFilter($filter)
public function setFilter(AbstractQuery $filter)
{
if ($filter instanceof AbstractFilter) {
trigger_error('Deprecated: Elastica\Aggregation\Filter\setFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', E_USER_DEPRECATED);
} elseif (!($filter instanceof AbstractQuery)) {
throw new InvalidException('Filter must be instance of AbstractQuery');
}

return $this->setParam('filter', $filter);
}

Expand Down
9 changes: 1 addition & 8 deletions lib/Elastica/Aggregation/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
use Elastica\Filter\AbstractFilter;
use Elastica\Query\AbstractQuery;

/**
Expand Down Expand Up @@ -30,14 +29,8 @@ class Filters extends AbstractAggregation
*
* @return $this
*/
public function addFilter($filter, $name = null)
public function addFilter(AbstractQuery $filter, $name = null)
{
if ($filter instanceof AbstractFilter) {
trigger_error('Deprecated: Elastica\Aggregation\Filters\addFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', E_USER_DEPRECATED);
} elseif (!($filter instanceof AbstractQuery)) {
throw new InvalidException('Filter must be instance of AbstractQuery');
}

if (null !== $name && !is_string($name)) {
throw new InvalidException('Name must be a string');
}
Expand Down
10 changes: 1 addition & 9 deletions lib/Elastica/Aggregation/SignificantTerms.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php
namespace Elastica\Aggregation;

use Elastica\Exception\InvalidException;
use Elastica\Filter\AbstractFilter;
use Elastica\Query\AbstractQuery;

/**
Expand All @@ -22,14 +20,8 @@ class SignificantTerms extends AbstractTermsAggregation
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html#_custom_background_context
*/
public function setBackgroundFilter($filter)
public function setBackgroundFilter(AbstractQuery $filter)
{
if ($filter instanceof AbstractFilter) {
trigger_error('Deprecated: Elastica\Aggregation\SignificantTerms::setBackgroundFilter passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', E_USER_DEPRECATED);
} elseif (!($filter instanceof AbstractQuery)) {
throw new InvalidException('Filter must be instance of AbstractQuery');
}

return $this->setParam('background_filter', $filter);
}
}
62 changes: 0 additions & 62 deletions lib/Elastica/Filter/AbstractFilter.php

This file was deleted.

200 changes: 0 additions & 200 deletions lib/Elastica/Filter/AbstractGeoDistance.php

This file was deleted.

Loading

0 comments on commit e5786fa

Please sign in to comment.