Skip to content

Commit ea670b4

Browse files
Add Elasticsearch 7 client in Elasticsearch 8 compatibility mode
1 parent 7e127de commit ea670b4

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

.github/workflows/test-application.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,16 @@ jobs:
8484
php-cs-fixer: false
8585
max-phpunit-version: '8'
8686

87+
- php-version: '8.4'
88+
elasticsearch-version: '8.14.3'
89+
elasticsearch-package-constraint: '~7.17.0'
90+
minimum-stability: 'dev'
91+
dependency-versions: 'highest'
92+
tools: 'composer:v2'
93+
php-cs-fixer: false
94+
max-phpunit-version: '8'
95+
composer-options: '--ignore-platform-reqs'
96+
8797
services:
8898
elasticsearch:
8999
image: elasticsearch:${{ matrix.elasticsearch-version }}
@@ -114,6 +124,7 @@ jobs:
114124
uses: ramsey/composer-install@v1
115125
with:
116126
dependency-versions: ${{matrix.dependency-versions}}
127+
composer-versions: ${{matrix.composer-options}}
117128

118129
- name: Run php-cs-fixer
119130
if: ${{ matrix.php-cs-fixer }}

Search/Adapter/ElasticSearchAdapter.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ public function __construct(Factory $factory, ElasticSearchClient $client, $vers
7878
$this->factory = $factory;
7979
$this->client = $client;
8080
$this->version = $version;
81+
82+
if (\version_compare($this->version, '7.11.0', '>=')) {
83+
$client->setConnectionParams([
84+
'client' => [
85+
'headers' => [
86+
'Accept' => ['application/vnd.elasticsearch+json;compatible-with=7'],
87+
'Content-Type' => ['application/vnd.elasticsearch+json;compatible-with=7'],
88+
],
89+
],
90+
]);
91+
}
8192
}
8293

8394
public function index(Document $document, $indexName)

0 commit comments

Comments
 (0)