Skip to content

Conversation

sidz
Copy link
Contributor

@sidz sidz commented Mar 27, 2023

Q A
Branch? main
Tickets #5430
License MIT

This PR adds elasticsearch 8 compatibility.

I've choose 8.4 as ClientInterface was introduced since 8.4 version and Client is marked as final.

$client = $this->prophesize(Client::class);
$clientClass = class_exists(\Elasticsearch\Client::class) ? \Elasticsearch\Client::class : \Elastic\Elasticsearch\ClientInterface::class;

$client = $this->prophesize($clientClass);
Copy link
Contributor Author

@sidz sidz Mar 28, 2023

Choose a reason for hiding this comment

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

Elastic\Elasticsearch\ClientInterface doesn't have cat method defined inside of it and it is not possible to mock method which does not exist. On other hand I couldn't rely on Elastic\Elasticsearch\Client as it is marked as final. ¯_(ツ)_/¯

So here I'm a bit stuck and don't see any good solution which will cover both >= 8.0 and <8.0 elasticsearch official clients.

p.s. For this reason all unit tests failed

Copy link
Member

Choose a reason for hiding this comment

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

We should avoid changing existing tests, duplicate the tests you need, don't test the cat with es > 8


$indexClient->delete(['index' => $index]);
if ($indexes !== []) {
$this->client->indices()->delete([
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove all indexes within a single http request instead of multiple HTTP requests

@soyuka
Copy link
Member

soyuka commented Mar 29, 2023

this looks really awesome, I'll review on friday / this week-end can't for now but I've got your messages!

@sidz sidz changed the title Add >= elasticsearch 8.4 compatibility Add compatibility with elasticsearch >= 8.4 Mar 29, 2023
Copy link
Member

@soyuka soyuka left a comment

Choose a reason for hiding this comment

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

Nice job so far, some few leftovers.

$clientClass = class_exists(\Elasticsearch\Client::class) ? \Elasticsearch\Client::class : \Elastic\Elasticsearch\Client::class;

$clientDefinition = new Definition($clientClass);
$clientDefinition->setPublic(false);
Copy link
Member

Choose a reason for hiding this comment

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

you don't need that or do you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$client = $this->prophesize(Client::class);
$clientClass = class_exists(\Elasticsearch\Client::class) ? \Elasticsearch\Client::class : \Elastic\Elasticsearch\ClientInterface::class;

$client = $this->prophesize($clientClass);
Copy link
Member

Choose a reason for hiding this comment

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

We should avoid changing existing tests, duplicate the tests you need, don't test the cat with es > 8

@stale
Copy link

stale bot commented Jun 24, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 24, 2023
@stale stale bot closed this Jul 1, 2023
@turegjorup
Copy link

Would love to see this ready for 3.2 - any way to help get this PR going again?

@soyuka soyuka reopened this Aug 22, 2023
@stale stale bot removed the stale label Aug 22, 2023
@soyuka
Copy link
Member

soyuka commented Aug 22, 2023

wow stale bot this wasn't supposed to be close :D sorry!

@ToshY
Copy link

ToshY commented Aug 28, 2023

@soyuka

  1. Should When compatibility elasticsearch/elasticsearch 8.* #5430 not be re-opened until this is merged?
  2. The milestone for 3.2 is set for September 1, 2023. Will this feature be included?

@soyuka
Copy link
Member

soyuka commented Aug 28, 2023

yes someone needs to rebase and finish this I think that we should just remove the TypeHint for now within the providers so keep them as flexible as possible for the feature (just add a phpdoc).

@sidz
Copy link
Contributor Author

sidz commented Aug 28, 2023

I'll do it

@sidz
Copy link
Contributor Author

sidz commented Aug 31, 2023

ready for re-review @soyuka

@soyuka
Copy link
Member

soyuka commented Sep 4, 2023

I'll continue this at #5795

@soyuka soyuka closed this Sep 4, 2023
@sidz sidz deleted the add-elasticsearch-8-compatibility branch September 4, 2023 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants