diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml
index 7d4782f3..a80dfdd7 100644
--- a/.github/workflows/test-application.yaml
+++ b/.github/workflows/test-application.yaml
@@ -61,6 +61,14 @@ jobs:
tools: 'composer:v2'
php-cs-fixer: false
+ - php-version: '8.5'
+ elasticsearch-version: '8.14.3'
+ elasticsearch-package-constraint: '~7.17.0'
+ minimum-stability: 'dev'
+ dependency-versions: 'highest'
+ tools: 'composer:v2'
+ php-cs-fixer: false
+
services:
elasticsearch:
image: elasticsearch:${{ matrix.elasticsearch-version }}
diff --git a/Resources/config/adapter_elastic.xml b/Resources/config/adapter_elastic.xml
index 87e6a3d7..43cab081 100644
--- a/Resources/config/adapter_elastic.xml
+++ b/Resources/config/adapter_elastic.xml
@@ -15,6 +15,7 @@
%massive_search.adapter.elastic.hosts%
+ %massive_search.adapter.elastic.version%
diff --git a/Search/Adapter/Elastic/ClientFactory.php b/Search/Adapter/Elastic/ClientFactory.php
index b1c31cea..244ceb00 100644
--- a/Search/Adapter/Elastic/ClientFactory.php
+++ b/Search/Adapter/Elastic/ClientFactory.php
@@ -28,6 +28,22 @@ class ClientFactory
*/
public static function create($config)
{
- return ClientBuilder::create()->setHosts($config['hosts'])->build();
+ $clientBuilder = ClientBuilder::create()->setHosts($config['hosts']);
+
+ $elasticSearchVersion = defined(Client::class . '::VERSION') ? Client::VERSION : '5.0';
+ $version = $config['version'] ?? $elasticSearchVersion;
+
+ if (\version_compare($version, '7.11.0', '>=')) {
+ $clientBuilder->setConnectionParams([
+ 'client' => [
+ 'headers' => [
+ 'Accept' => ['application/vnd.elasticsearch+json;compatible-with=7'],
+ 'Content-Type' => ['application/vnd.elasticsearch+json;compatible-with=7'],
+ ],
+ ],
+ ]);
+ }
+
+ return $clientBuilder->build();
}
}
diff --git a/Tests/docker/docker-elasticsearch-8-19.yml b/Tests/docker/docker-elasticsearch-8-19.yml
new file mode 100644
index 00000000..0ae7c172
--- /dev/null
+++ b/Tests/docker/docker-elasticsearch-8-19.yml
@@ -0,0 +1,19 @@
+services:
+ elasticsearch:
+ image: docker.elastic.co/elasticsearch/elasticsearch:8.19.0
+ environment:
+ discovery.type: single-node
+ xpack.security.enabled: 'false'
+ cluster.routing.allocation.disk.threshold_enabled: 'false'
+ ports:
+ - "9200:9200"
+ healthcheck:
+ test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
+ interval: 5s
+ timeout: 5s
+ retries: 20
+ volumes:
+ - elasticsearch-data:/usr/share/elasticsearch/data
+
+volumes:
+ elasticsearch-data:
diff --git a/composer.json b/composer.json
index a219f5b8..8c1cce39 100644
--- a/composer.json
+++ b/composer.json
@@ -51,7 +51,8 @@
"conflict": {
"guzzlehttp/ringphp": "< 1.0.7",
"symfony/security-guard": "5.4.0-BETA1",
- "doctrine/doctrine-cache-bundle": "<1.3.1"
+ "doctrine/doctrine-cache-bundle": "<1.3.1",
+ "elasticsearch/elasticsearch": "<2.0 || >=8.0"
},
"autoload": {
"psr-4": {