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

WIP: Add Elasticsearch 7 client in Elasticsearch 8 compatibility mode #170

Draft
wants to merge 3 commits into
base: 2.9
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 11 additions & 1 deletion .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 All @@ -132,5 +143,4 @@ jobs:
run: vendor/bin/behat --suite=zend_lucene

- name: Execute elastic behat tests
if: ${{ matrix.php-version < '8.0' }} # requires fixing elastic tests on 7.11 (sorting)
run: vendor/bin/behat --suite=elastic
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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": {
Expand Down
Loading