Skip to content

Commit 3b2b7c3

Browse files
committed
Merge pull request #50 from mvar/deprecate_filters
Deprecate filters
2 parents a644572 + 0e82d75 commit 3b2b7c3

File tree

119 files changed

+1816
-902
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1816
-902
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ before_script:
1313
- composer install --no-interaction --prefer-dist
1414
script:
1515
- vendor/bin/phpunit --coverage-clover=coverage.clover
16-
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/ ./
16+
- vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor/,src/Filter/ ./
1717
after_script:
1818
- vendor/bin/coveralls
1919
notifications:

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CHANGELOG
2+
=========
3+
4+
v1.x (201x)
5+
---
6+
7+
- Fixed nested query in case `bool` with single `must` clause given (#32)
8+
- Deprecated all filters and filtered query (#50)
9+
- Added `filter` clause support for `BoolQuery` (#48)
10+
11+
v1.0.1 (2015-12-16)
12+
---
13+
14+
- Fixed `function_score` query options handling (#35)
15+
- Added Symfony 3 compatibility
16+
- Added support for `timeout` and `terminate_after` options in Search endpoint (#34)

docs/Filter/Or.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Or Filter
22

3+
__DEPRECATED:__ `OrFilter` is deprecated and will be removed in 2.0. Use `BoolQuery` instead.
4+
35
> More info about or filter is in the [official elasticsearch docs][1]
46
57
A filter that matches documents using the OR boolean operator on other filters.

src/Filter/AndFilter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@
1111

1212
namespace ONGR\ElasticsearchDSL\Filter;
1313

14+
@trigger_error(
15+
'The AndFilter class is deprecated and will be removed in 2.0. Use BoolQuery instead.',
16+
E_USER_DEPRECATED
17+
);
18+
1419
use ONGR\ElasticsearchDSL\BuilderInterface;
1520
use ONGR\ElasticsearchDSL\ParametersTrait;
1621

1722
/**
1823
* Represents Elasticsearch "and" filter.
1924
*
2025
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
26+
*
27+
* @deprecated Will be removed in 2.0. Use the BoolQuery instead.
2128
*/
2229
class AndFilter implements BuilderInterface
2330
{

src/Filter/BoolFilter.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@
1111

1212
namespace ONGR\ElasticsearchDSL\Filter;
1313

14+
@trigger_error(
15+
'The BoolFilter class is deprecated and will be removed in 2.0. Use BoolQuery instead.',
16+
E_USER_DEPRECATED
17+
);
18+
1419
use ONGR\ElasticsearchDSL\Query\BoolQuery;
1520

1621
/**
1722
* Represents Elasticsearch "bool" filter.
1823
*
1924
* @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html
25+
*
26+
* @deprecated Will be removed in 2.0. Use the BoolQuery instead.
2027
*/
2128
class BoolFilter extends BoolQuery
2229
{

src/Filter/ExistsFilter.php

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,43 +11,20 @@
1111

1212
namespace ONGR\ElasticsearchDSL\Filter;
1313

14-
use ONGR\ElasticsearchDSL\BuilderInterface;
14+
@trigger_error(
15+
'The ExistsFilter class is deprecated and will be removed in 2.0. Use ExistsQuery instead.',
16+
E_USER_DEPRECATED
17+
);
18+
19+
use ONGR\ElasticsearchDSL\Query\ExistsQuery;
1520

1621
/**
1722
* Represents Elasticsearch "exists" filter.
1823
*
1924
* @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-exists-filter.html
25+
*
26+
* @deprecated Will be removed in 2.0. Use the ExistsQuery instead.
2027
*/
21-
class ExistsFilter implements BuilderInterface
28+
class ExistsFilter extends ExistsQuery
2229
{
23-
/**
24-
* @var string
25-
*/
26-
private $field;
27-
28-
/**
29-
* @param string $field Field value.
30-
*/
31-
public function __construct($field)
32-
{
33-
$this->field = $field;
34-
}
35-
36-
/**
37-
* {@inheritdoc}
38-
*/
39-
public function getType()
40-
{
41-
return 'exists';
42-
}
43-
44-
/**
45-
* {@inheritdoc}
46-
*/
47-
public function toArray()
48-
{
49-
return [
50-
'field' => $this->field,
51-
];
52-
}
5330
}

src/Filter/GeoBoundingBoxFilter.php

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -11,73 +11,18 @@
1111

1212
namespace ONGR\ElasticsearchDSL\Filter;
1313

14-
use ONGR\ElasticsearchDSL\BuilderInterface;
15-
use ONGR\ElasticsearchDSL\ParametersTrait;
14+
@trigger_error(
15+
'The GeoBoundingBoxFilter class is deprecated and will be removed in 2.0. Use GeoBoundingBoxQuery instead.',
16+
E_USER_DEPRECATED
17+
);
18+
19+
use ONGR\ElasticsearchDSL\Query\GeoBoundingBoxQuery;
1620

1721
/**
1822
* Represents Elasticsearch "Geo Bounding Box" filter.
23+
*
24+
* @deprecated Will be removed in 2.0. Use the GeoBoundingBoxQuery instead.
1925
*/
20-
class GeoBoundingBoxFilter implements BuilderInterface
26+
class GeoBoundingBoxFilter extends GeoBoundingBoxQuery
2127
{
22-
use ParametersTrait;
23-
24-
/**
25-
* @var array
26-
*/
27-
private $values;
28-
29-
/**
30-
* @var string
31-
*/
32-
private $field;
33-
34-
/**
35-
* @param string $field
36-
* @param array $values
37-
* @param array $parameters
38-
*/
39-
public function __construct($field, $values, array $parameters = [])
40-
{
41-
$this->field = $field;
42-
$this->values = $values;
43-
$this->setParameters($parameters);
44-
}
45-
46-
/**
47-
* {@inheritdoc}
48-
*/
49-
public function getType()
50-
{
51-
return 'geo_bounding_box';
52-
}
53-
54-
/**
55-
* {@inheritdoc}
56-
*/
57-
public function toArray()
58-
{
59-
if (count($this->values) === 2) {
60-
$query = [
61-
$this->field => [
62-
'top_left' => $this->values[0],
63-
'bottom_right' => $this->values[1],
64-
],
65-
];
66-
} elseif (count($this->values) === 4) {
67-
$query = [
68-
$this->field => [
69-
'top' => $this->values[0],
70-
'left' => $this->values[1],
71-
'bottom' => $this->values[2],
72-
'right' => $this->values[3],
73-
],
74-
];
75-
} else {
76-
throw new \LogicException('Geo Bounding Box filter must have 2 or 4 geo points set.');
77-
}
78-
79-
$output = $this->processArray($query);
80-
81-
return $output;
82-
}
8328
}

src/Filter/GeoDistanceFilter.php

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,18 @@
1111

1212
namespace ONGR\ElasticsearchDSL\Filter;
1313

14-
use ONGR\ElasticsearchDSL\BuilderInterface;
15-
use ONGR\ElasticsearchDSL\ParametersTrait;
14+
@trigger_error(
15+
'The GeoDistanceFilter class is deprecated and will be removed in 2.0. Use GeoDistanceQuery instead.',
16+
E_USER_DEPRECATED
17+
);
18+
19+
use ONGR\ElasticsearchDSL\Query\GeoDistanceQuery;
1620

1721
/**
1822
* Represents Elasticsearch "Geo Distance Filter" filter.
23+
*
24+
* @deprecated Will be removed in 2.0. Use the GeoDistanceQuery instead.
1925
*/
20-
class GeoDistanceFilter implements BuilderInterface
26+
class GeoDistanceFilter extends GeoDistanceQuery
2127
{
22-
use ParametersTrait;
23-
24-
/**
25-
* @var string
26-
*/
27-
private $field;
28-
29-
/**
30-
* @var string
31-
*/
32-
private $distance;
33-
34-
/**
35-
* @var mixed
36-
*/
37-
private $location;
38-
39-
/**
40-
* @param string $field
41-
* @param string $distance
42-
* @param mixed $location
43-
* @param array $parameters
44-
*/
45-
public function __construct($field, $distance, $location, array $parameters = [])
46-
{
47-
$this->field = $field;
48-
$this->distance = $distance;
49-
$this->location = $location;
50-
51-
$this->setParameters($parameters);
52-
}
53-
54-
/**
55-
* {@inheritdoc}
56-
*/
57-
public function getType()
58-
{
59-
return 'geo_distance';
60-
}
61-
62-
/**
63-
* {@inheritdoc}
64-
*/
65-
public function toArray()
66-
{
67-
$query = [
68-
'distance' => $this->distance,
69-
$this->field => $this->location,
70-
];
71-
$output = $this->processArray($query);
72-
73-
return $output;
74-
}
7528
}

src/Filter/GeoDistanceRangeFilter.php

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,18 @@
1111

1212
namespace ONGR\ElasticsearchDSL\Filter;
1313

14-
use ONGR\ElasticsearchDSL\BuilderInterface;
15-
use ONGR\ElasticsearchDSL\ParametersTrait;
14+
@trigger_error(
15+
'The GeoDistanceRangeFilter class is deprecated and will be removed in 2.0. Use GeoDistanceRangeQuery instead.',
16+
E_USER_DEPRECATED
17+
);
18+
19+
use ONGR\ElasticsearchDSL\Query\GeoDistanceRangeQuery;
1620

1721
/**
1822
* Represents Elasticsearch "Geo Distance Range Filter" filter.
23+
*
24+
* @deprecated Will be removed in 2.0. Use the GeoDistanceRangeQuery instead.
1925
*/
20-
class GeoDistanceRangeFilter implements BuilderInterface
26+
class GeoDistanceRangeFilter extends GeoDistanceRangeQuery
2127
{
22-
use ParametersTrait;
23-
24-
/**
25-
* @var string
26-
*/
27-
private $field;
28-
29-
/**
30-
* @var array
31-
*/
32-
private $range;
33-
34-
/**
35-
* @var mixed
36-
*/
37-
private $location;
38-
39-
/**
40-
* @param string $field
41-
* @param array $range
42-
* @param mixed $location
43-
* @param array $parameters
44-
*/
45-
public function __construct($field, $range, $location, array $parameters = [])
46-
{
47-
$this->field = $field;
48-
$this->range = $range;
49-
$this->location = $location;
50-
51-
$this->setParameters($parameters);
52-
}
53-
54-
/**
55-
* {@inheritdoc}
56-
*/
57-
public function getType()
58-
{
59-
return 'geo_distance_range';
60-
}
61-
62-
/**
63-
* {@inheritdoc}
64-
*/
65-
public function toArray()
66-
{
67-
$query = $this->range + [$this->field => $this->location];
68-
$output = $this->processArray($query);
69-
70-
return $output;
71-
}
7228
}

0 commit comments

Comments
 (0)