Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch 8.x Support #18

Merged
merged 23 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
df2d7cf
bulk changes for phpunit9 deprecation warnings of the test cases
hkulekci Feb 16, 2022
176c5e7
Merge pull request #1 from hkulekci/phpunit-9-warnings-fixed
hkulekci Feb 16, 2022
ef4ebaf
composer update and readme changes for elasticsearch 8.0
hkulekci Feb 16, 2022
6a7af66
MovingAverage pipeline aggregation removed for ES8.x
hkulekci Feb 16, 2022
0675b13
Remove deprecated _time and _term sort orders
hkulekci Feb 16, 2022
3e5759f
Remove deprecated date histogram interval and changed as calendar_int…
hkulekci Feb 16, 2022
fce8532
php 7.1 support droped and the version increased to ^7.4
hkulekci Feb 16, 2022
c177324
php 7.1, 7.2 and 7.3 remove d from the github ci
hkulekci Feb 16, 2022
08883b4
phpcs fix for the changes
hkulekci Feb 16, 2022
3fba68b
phpunit upgraged to 9.x
hkulekci Feb 17, 2022
19b05eb
::class used instead of text
hkulekci Feb 20, 2022
6d9a3e2
Removes typed endpoint from search on tests
hkulekci Feb 20, 2022
41b790a
cutoff_frequency sample removed for CommonTerms query
hkulekci Feb 20, 2022
edc8829
Remove CommonTermsQuery and cutoff_frequency params
hkulekci Feb 20, 2022
46c8b52
functional test for date histogram
hkulekci Feb 20, 2022
b327422
elasticsearch version increased for the test node
hkulekci Feb 20, 2022
e346467
removed e_user_deprecated exceptions for GeoShape query
hkulekci Feb 20, 2022
cac247d
Merge pull request #2 from hkulekci/elasticsearch-8.0-support
hkulekci Feb 27, 2022
a77837c
php8.1 added on test matrix
hkulekci Mar 2, 2022
ad88b0f
upgrade the version of elasticsearch to 8.0.0
hkulekci Mar 25, 2022
9b070a0
fix for the elasticsearch-php version
hkulekci Mar 25, 2022
2594f11
Update composer.json
alexander-schranz Mar 25, 2022
f007749
Add a psr 18 client implementation (nyholm/psr7)
alexander-schranz Mar 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.1'
lint: false
symfony-version: '^2.8'

- php-version: '7.2'
lint: false
symfony-version: '^3.4'

- php-version: '7.3'
lint: false
symfony-version: '^4.4'
alexander-schranz marked this conversation as resolved.
Show resolved Hide resolved

- php-version: '7.4'
lint: true
symfony-version: '^5.0'
Expand All @@ -36,9 +24,13 @@ jobs:
lint: true
symfony-version: '^5.0'

- php-version: '8.1'
lint: true
symfony-version: '^5.0'

services:
elasticsearch:
image: elasticsearch:7.5.2
image: elasticsearch:8.0.0
ports:
- 9200:9200
env:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ With some basic changes to support wider range of Symfony Versions.

| Version | Supported Elasticsearch Version | Supported Symfony Version |
|---------|---------------------------------|---------------------------|
| 8.x | ^8.0 | ^5.0, |
| 7.x | ^7.0 | ^5.0, ^4.0, ^3.4, ^2.8 |
| 6.x | ^6.0 | ^5.0, ^4.0, ^3.4, ^2.8 |
| 5.x | ^5.0 | ^5.0, ^4.0, ^3.4, ^2.8 |
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
{
"name": "Handcrafted in the Alps Team",
"homepage": "https://github.com/handcraftedinthealps/ElasticsearchDSL/graphs/contributors"
},
{
"name": "Haydar KULEKCI",
"homepage": "https://github.com/hkulekci/ElasticsearchDSL/graphs/contributors"
}
],
"require": {
"php": "^7.1|^8.0",
"php": "^7.4 || ^8.0",
"symfony/serializer": "^2.8 || ^3.4 || ^4.0 || ^5.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You did write that Symfony 4.4 is not longer supported then we should adjust it here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, I could not be sure about this version matrix. Let me think about it a little bit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can also allow and test against symfony ^6.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also need to discuss it internal if we need to support Elasticsearch 8 for Symfony 3.4 because of @sulu ArticleBundle 1.2 Version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. Let me know the decision of the internal discussion. As I see on my local test, all the versions are working, but I could not test with full Symfony, and I rely on tests.

"elasticsearch/elasticsearch": "^7.0"
"elasticsearch/elasticsearch": "8.0.*"
},
"require-dev": {
"phpunit/phpunit": "^5.7.26 || ^7.5.20 || ^8.0",
"nyholm/psr7": "^1.5",
"phpunit/phpunit": "^5.7.26 || ^7.5.20 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^2.0 || ^3.0"
},
"suggest": {
Expand Down
6 changes: 3 additions & 3 deletions docs/Aggregation/Bucketing/DateHistogram.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Example of expressions for interval: `year`, `quarter`, `month`, `week`, `day`,
"articles_over_time" : {
"date_histogram" : {
"field" : "date",
"interval" : "month"
"calendar_interval" : "month"
}
}
}
Expand Down Expand Up @@ -42,7 +42,7 @@ to provide a custom format to the results of the query:
"articles_over_time" : {
"date_histogram" : {
"field" : "date",
"interval" : "1M",
"calendar_interval" : "1M",
"format" : "yyyy-MM-dd"
}
}
Expand All @@ -63,4 +63,4 @@ $search->addAggregation($dateHistogramAggregation);
$queryArray = $search->toArray();

```
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
[1]: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
46 changes: 0 additions & 46 deletions docs/Query/FullText/CommonTerms.md

This file was deleted.

75 changes: 66 additions & 9 deletions src/Aggregation/Bucketing/DateHistogramAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ class DateHistogramAggregation extends AbstractAggregation
*/
protected $interval;

/**
* @var string
*/
protected $calendarInterval;

/**
* @var string
*/
protected $fixedInterval;

/**
* @var string
*/
Expand All @@ -37,34 +47,76 @@ class DateHistogramAggregation extends AbstractAggregation
* Inner aggregations container init.
*
* @param string $name
* @param string $field
* @param string $interval
* @param string|null $field
* @param string|null $interval
* @param string|null $format
*/
public function __construct($name, $field = null, $interval = null, $format = null)
public function __construct($name, string $field = null, string $interval = null, string $format = null)
{
parent::__construct($name);

$this->setField($field);
$this->setInterval($interval);
$this->setCalendarInterval($interval);
$this->setFormat($format);
}

/**
* @return int
* @return string
* @deprecated use getCalendarInterval instead
*/
public function getInterval()
{
return $this->interval;
return $this->calendarInterval;
}

/**
* @param string $interval
* @deprecated use setCalendarInterval instead
*
* @return $this
*/
public function setInterval($interval)
{
$this->interval = $interval;
$this->setCalendarInterval($interval);

return $this;
}


/**
* @return string
*/
public function getFixedInterval()
{
return $this->fixedInterval;
}

/**
* @param string $interval
* @return $this
*/
public function setFixedInterval($interval)
{
$this->fixedInterval = $interval;

return $this;
}

/**
* @return string
*/
public function getCalendarInterval()
{
return $this->calendarInterval;
}

/**
* @param string $interval
* @return $this
*/
public function setCalendarInterval($interval)
{
$this->calendarInterval = $interval;

return $this;
}
Expand Down Expand Up @@ -94,15 +146,20 @@ public function getType()
*/
public function getArray()
{
if (!$this->getField() || !$this->getInterval()) {
if (!$this->getField() || !($this->getCalendarInterval() || $this->getFixedInterval())) {
throw new \LogicException('Date histogram aggregation must have field and interval set.');
}

$out = [
'field' => $this->getField(),
'interval' => $this->getInterval(),
];

if ($this->getCalendarInterval()) {
$out['calendar_interval'] = $this->getCalendarInterval();
} elseif ($this->getFixedInterval()) {
$out['fixed_interval'] = $this->getFixedInterval();
}

if (!empty($this->format)) {
$out['format'] = $this->format;
}
Expand Down
17 changes: 11 additions & 6 deletions src/Aggregation/Metric/PercentilesAggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ class PercentilesAggregation extends AbstractAggregation
* Inner aggregations container init.
*
* @param string $name
* @param string $field
* @param array $percents
* @param string $script
* @param int $compression
* @param string|null $field
* @param array|null $percents
* @param string|null $script
* @param int|null $compression
*/
public function __construct($name, $field = null, $percents = null, $script = null, $compression = null)
{
public function __construct(
string $name,
string $field = null,
array $percents = null,
string $script = null,
int $compression = null
) {
parent::__construct($name);

$this->setField($field);
Expand Down
28 changes: 0 additions & 28 deletions src/Aggregation/Pipeline/MovingAverageAggregation.php

This file was deleted.

6 changes: 3 additions & 3 deletions src/BuilderBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ public function get($name)
*
* @return BuilderInterface[]
*/
public function all($type = null)
public function all(string $type = null)
{
return array_filter(
$this->bag,
/** @var BuilderInterface $builder */
function (BuilderInterface $builder) use ($type) {
return $type === null || $builder->getType() == $type;
static function (BuilderInterface $builder) use ($type) {
return $type === null || $builder->getType() === $type;
}
);
}
Expand Down
Loading