Skip to content

Commit

Permalink
Add Elasticsearch 7 client in Elasticsearch 8 compatibility mode
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz committed Jul 18, 2024
1 parent 7e127de commit ea670b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ jobs:
php-cs-fixer: false
max-phpunit-version: '8'

- php-version: '8.4'
elasticsearch-version: '8.14.3'
elasticsearch-package-constraint: '~7.17.0'
minimum-stability: 'dev'
dependency-versions: 'highest'
tools: 'composer:v2'
php-cs-fixer: false
max-phpunit-version: '8'
composer-options: '--ignore-platform-reqs'

services:
elasticsearch:
image: elasticsearch:${{ matrix.elasticsearch-version }}
Expand Down Expand Up @@ -114,6 +124,7 @@ jobs:
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{matrix.dependency-versions}}
composer-versions: ${{matrix.composer-options}}

- name: Run php-cs-fixer
if: ${{ matrix.php-cs-fixer }}
Expand Down
11 changes: 11 additions & 0 deletions Search/Adapter/ElasticSearchAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ public function __construct(Factory $factory, ElasticSearchClient $client, $vers
$this->factory = $factory;
$this->client = $client;
$this->version = $version;

if (\version_compare($this->version, '7.11.0', '>=')) {
$client->setConnectionParams([
'client' => [
'headers' => [
'Accept' => ['application/vnd.elasticsearch+json;compatible-with=7'],
'Content-Type' => ['application/vnd.elasticsearch+json;compatible-with=7'],
],
],
]);
}
}

public function index(Document $document, $indexName)
Expand Down

0 comments on commit ea670b4

Please sign in to comment.