Skip to content

Commit cac247d

Browse files
authored
Merge pull request #2 from hkulekci/elasticsearch-8.0-support
Elasticsearch 8.0 support
2 parents 176c5e7 + e346467 commit cac247d

25 files changed

+245
-266
lines changed

.github/workflows/test-application.yaml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- php-version: '7.1'
20-
lint: false
21-
symfony-version: '^2.8'
22-
23-
- php-version: '7.2'
24-
lint: false
25-
symfony-version: '^3.4'
26-
27-
- php-version: '7.3'
28-
lint: false
29-
symfony-version: '^4.4'
30-
3119
- php-version: '7.4'
3220
lint: true
3321
symfony-version: '^5.0'
@@ -38,7 +26,7 @@ jobs:
3826

3927
services:
4028
elasticsearch:
41-
image: elasticsearch:7.5.2
29+
image: elasticsearch:8.0.0
4230
ports:
4331
- 9200:9200
4432
env:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ With some basic changes to support wider range of Symfony Versions.
55

66
| Version | Supported Elasticsearch Version | Supported Symfony Version |
77
|---------|---------------------------------|---------------------------|
8+
| 8.x | ^8.0 | ^5.0, |
89
| 7.x | ^7.0 | ^5.0, ^4.0, ^3.4, ^2.8 |
910
| 6.x | ^6.0 | ^5.0, ^4.0, ^3.4, ^2.8 |
1011
| 5.x | ^5.0 | ^5.0, ^4.0, ^3.4, ^2.8 |

composer.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
{
1313
"name": "Handcrafted in the Alps Team",
1414
"homepage": "https://github.com/handcraftedinthealps/ElasticsearchDSL/graphs/contributors"
15+
},
16+
{
17+
"name": "Haydar KULEKCI",
18+
"homepage": "https://github.com/hkulekci/ElasticsearchDSL/graphs/contributors"
1519
}
1620
],
1721
"require": {
18-
"php": "^7.1|^8.0",
22+
"php": "^7.4 || ^8.0",
1923
"symfony/serializer": "^2.8 || ^3.4 || ^4.0 || ^5.0",
20-
"elasticsearch/elasticsearch": "^7.0"
24+
"elasticsearch/elasticsearch": "^8.0"
2125
},
2226
"require-dev": {
23-
"phpunit/phpunit": "^5.7.26 || ^7.5.20 || ^8.0",
27+
"phpunit/phpunit": "^5.7.26 || ^7.5.20 || ^8.0 || ^9.0",
2428
"squizlabs/php_codesniffer": "^2.0 || ^3.0"
2529
},
2630
"suggest": {

docs/Aggregation/Bucketing/DateHistogram.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Example of expressions for interval: `year`, `quarter`, `month`, `week`, `day`,
1313
"articles_over_time" : {
1414
"date_histogram" : {
1515
"field" : "date",
16-
"interval" : "month"
16+
"calendar_interval" : "month"
1717
}
1818
}
1919
}
@@ -42,7 +42,7 @@ to provide a custom format to the results of the query:
4242
"articles_over_time" : {
4343
"date_histogram" : {
4444
"field" : "date",
45-
"interval" : "1M",
45+
"calendar_interval" : "1M",
4646
"format" : "yyyy-MM-dd"
4747
}
4848
}
@@ -63,4 +63,4 @@ $search->addAggregation($dateHistogramAggregation);
6363
$queryArray = $search->toArray();
6464

6565
```
66-
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
66+
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html

docs/Query/FullText/CommonTerms.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/Aggregation/Bucketing/DateHistogramAggregation.php

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ class DateHistogramAggregation extends AbstractAggregation
2828
*/
2929
protected $interval;
3030

31+
/**
32+
* @var string
33+
*/
34+
protected $calendarInterval;
35+
36+
/**
37+
* @var string
38+
*/
39+
protected $fixedInterval;
40+
3141
/**
3242
* @var string
3343
*/
@@ -37,34 +47,76 @@ class DateHistogramAggregation extends AbstractAggregation
3747
* Inner aggregations container init.
3848
*
3949
* @param string $name
40-
* @param string $field
41-
* @param string $interval
50+
* @param string|null $field
51+
* @param string|null $interval
52+
* @param string|null $format
4253
*/
43-
public function __construct($name, $field = null, $interval = null, $format = null)
54+
public function __construct($name, string $field = null, string $interval = null, string $format = null)
4455
{
4556
parent::__construct($name);
4657

4758
$this->setField($field);
48-
$this->setInterval($interval);
59+
$this->setCalendarInterval($interval);
4960
$this->setFormat($format);
5061
}
5162

5263
/**
53-
* @return int
64+
* @return string
65+
* @deprecated use getCalendarInterval instead
5466
*/
5567
public function getInterval()
5668
{
57-
return $this->interval;
69+
return $this->calendarInterval;
5870
}
5971

6072
/**
6173
* @param string $interval
74+
* @deprecated use setCalendarInterval instead
6275
*
6376
* @return $this
6477
*/
6578
public function setInterval($interval)
6679
{
67-
$this->interval = $interval;
80+
$this->setCalendarInterval($interval);
81+
82+
return $this;
83+
}
84+
85+
86+
/**
87+
* @return string
88+
*/
89+
public function getFixedInterval()
90+
{
91+
return $this->fixedInterval;
92+
}
93+
94+
/**
95+
* @param string $interval
96+
* @return $this
97+
*/
98+
public function setFixedInterval($interval)
99+
{
100+
$this->fixedInterval = $interval;
101+
102+
return $this;
103+
}
104+
105+
/**
106+
* @return string
107+
*/
108+
public function getCalendarInterval()
109+
{
110+
return $this->calendarInterval;
111+
}
112+
113+
/**
114+
* @param string $interval
115+
* @return $this
116+
*/
117+
public function setCalendarInterval($interval)
118+
{
119+
$this->calendarInterval = $interval;
68120

69121
return $this;
70122
}
@@ -94,15 +146,20 @@ public function getType()
94146
*/
95147
public function getArray()
96148
{
97-
if (!$this->getField() || !$this->getInterval()) {
149+
if (!$this->getField() || !($this->getCalendarInterval() || $this->getFixedInterval())) {
98150
throw new \LogicException('Date histogram aggregation must have field and interval set.');
99151
}
100152

101153
$out = [
102154
'field' => $this->getField(),
103-
'interval' => $this->getInterval(),
104155
];
105156

157+
if ($this->getCalendarInterval()) {
158+
$out['calendar_interval'] = $this->getCalendarInterval();
159+
} elseif ($this->getFixedInterval()) {
160+
$out['fixed_interval'] = $this->getFixedInterval();
161+
}
162+
106163
if (!empty($this->format)) {
107164
$out['format'] = $this->format;
108165
}

src/Aggregation/Metric/PercentilesAggregation.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ class PercentilesAggregation extends AbstractAggregation
3939
* Inner aggregations container init.
4040
*
4141
* @param string $name
42-
* @param string $field
43-
* @param array $percents
44-
* @param string $script
45-
* @param int $compression
42+
* @param string|null $field
43+
* @param array|null $percents
44+
* @param string|null $script
45+
* @param int|null $compression
4646
*/
47-
public function __construct($name, $field = null, $percents = null, $script = null, $compression = null)
48-
{
47+
public function __construct(
48+
string $name,
49+
string $field = null,
50+
array $percents = null,
51+
string $script = null,
52+
int $compression = null
53+
) {
4954
parent::__construct($name);
5055

5156
$this->setField($field);

src/Aggregation/Pipeline/MovingAverageAggregation.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/BuilderBag.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ public function get($name)
100100
*
101101
* @return BuilderInterface[]
102102
*/
103-
public function all($type = null)
103+
public function all(string $type = null)
104104
{
105105
return array_filter(
106106
$this->bag,
107107
/** @var BuilderInterface $builder */
108-
function (BuilderInterface $builder) use ($type) {
109-
return $type === null || $builder->getType() == $type;
108+
static function (BuilderInterface $builder) use ($type) {
109+
return $type === null || $builder->getType() === $type;
110110
}
111111
);
112112
}

src/Query/FullText/CommonTermsQuery.php

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)