elastically icon indicating copy to clipboard operation
elastically copied to clipboard

Plan to use `ruflin/elastica` version 8?

Open jmariller opened this issue 1 year ago • 23 comments

Hi,

First of all thank you for this library :-)

I am wondering if it is planned to use version 8 of ruflin/elastica, and if so when more or less?

Many thanks

jmariller avatar May 24 '24 08:05 jmariller

We would be happy to see Pull Request about this yes. Can you work on this?

Some difficulties could arise:

  • the connections pool is now based on Elasticsearch custom https://github.com/elastic/elastic-transport-php - so our Symfony HttpClient bridge must probably be changed;
  • it will probably stop working with OpenSearch, see https://github.com/elastic/elasticsearch-php/issues/1347 (not tested)

I would love for our project to be compatible with both 7 and 8.

damienalexandre avatar May 24 '24 08:05 damienalexandre

Thank you @damienalexandre for your quick feedback! Sure I can invest some time to try & contribute :slightly_smiling_face:

jmariller avatar May 24 '24 08:05 jmariller

also I forgot to mention that I am not sure if we can make it work with both versions, as the namespace for different classes (e.g. Client) has changed between 7 and 8.

jmariller avatar May 24 '24 09:05 jmariller

The 8.0.0 version is now released https://github.com/ruflin/Elastica/releases/tag/8.0.0

VincentLanglet avatar May 29 '24 12:05 VincentLanglet

Thanks @VincentLanglet for the update!

@damienalexandre so I started to work on it and now I get following error message for many of the PhpUnit tests: Elastic\Transport\Exception\NoNodeAvailableException: Exceeded maximum number of retries (1)

I am missing anything, should I set some environment/configuration value?

jmariller avatar Jun 05 '24 14:06 jmariller

The tests are running against a real Elasticsearch.

You can run this:

make start
make test
make stop

It will boot a ES node via Docker and expose port 9999 (we don't use the default 9200 port to avoid touching any real Elasticsearch node you may have on your computer).

damienalexandre avatar Jun 05 '24 14:06 damienalexandre

I had actually tried to start the docker ES node as I saw the makefile, however I still get exactly the same error message :disappointed: any other idea?

jmariller avatar Jun 06 '24 06:06 jmariller

hi @damienalexandre so I tried once again to make this work without success, would you have any other hint?

jmariller avatar Jul 03 '24 13:07 jmariller

Could you show the console output? Can you run docker ps?

damienalexandre avatar Jul 03 '24 13:07 damienalexandre

sure, here it is:

console output (just an extract) image

docker ps image

jmariller avatar Jul 03 '24 13:07 jmariller

Can you open http://127.0.0.1:9999/ in a browser?

What does curl http://127.0.0.1:9999/ get you?

damienalexandre avatar Jul 03 '24 13:07 damienalexandre

This is what I get when opening this in a browser: image

And with curl (essentially the same): image

jmariller avatar Jul 03 '24 14:07 jmariller

I don't know what's happening but:

  • you have a working php
  • you have a working elasticsearch

Is there something we don't know? Do you have a proxy?

Can you go to http://127.0.0.1:9999/_cluster/health?pretty and paste the result?

damienalexandre avatar Jul 03 '24 14:07 damienalexandre

Thanks for taking the time to help :pray:

Here is the outcome of that URL:

{
"cluster_name": "docker-cluster",
"status": "green",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 0,
"active_shards": 0,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 100
}

jmariller avatar Jul 03 '24 14:07 jmariller

Status green, it should work!

You test from "master" or with your updated dependencies? It looks like the Elastica client is not properly configured, that may be a regression from version 8.

damienalexandre avatar Jul 03 '24 14:07 damienalexandre

aaah got it, it is indeed an issue from version 8! I reverted my changes and it works fine :tada: alright then, I need to investigate further :sweat_smile: thanks again so much for your support :pray:

ps: if anyone sees this and wants to help too, please do :slightly_smiling_face:

jmariller avatar Jul 03 '24 14:07 jmariller

FYI elastic/elasticsearch-php 8.0 is no more compatible with alternative servers like opensearch.

There is a mechanism that checks the headers https://github.com/elastic/elasticsearch-php/issues/1229

jderusse avatar Jul 04 '24 12:07 jderusse

thanks @jderusse I have actually also just noticed the same while trying to run the tests with elasticsearch without updating the docker image :+1:

@damienalexandre I am making some progress, now some more tests are green :tada:

jmariller avatar Jul 04 '24 13:07 jmariller

short update, now I have all tests green besides the one for the HttpClientTransport where I might need some help - I'll do as much as I can :slightly_smiling_face:

jmariller avatar Jul 05 '24 14:07 jmariller

Hi @jmariller ! Are you still working on this? Maybe I can help on the HttpClientTransport issue

GaryPEGEOT avatar Oct 23 '24 12:10 GaryPEGEOT

hi @GaryPEGEOT! no, at the moment I do not have capacity unfortunately. So if you could help it would be great - you can check out my PR and work directly on it if you want :slightly_smiling_face: thanks!

jmariller avatar Oct 23 '24 13:10 jmariller

Hi @damienalexandre!

Correct me if I'm wrong, but it looks like JoliCode\Elastically\Transport\HttpClientTransport will not have much sense with ruflin's Elastica v8:

  1. AbstractTransport is gone
  2. Elastic\Transport\Transport is a final class

And maybe more importantly, we don't really need it anymore, as you can specify $config['transport_config']['http_client'] directly, and provide it with your own Symfony\Component\HttpClient\Psr18Client.

We could update ElasticallyExtension so that given a client it automatically create the PSR client.

GaryPEGEOT avatar Oct 23 '24 13:10 GaryPEGEOT

You are absolutely right, and what you suggest looks good, thanks :+1:

damienalexandre avatar Oct 23 '24 13:10 damienalexandre

I'm creating a PR on damien's fork to remove the transport while adding test to make sure you can specify your own PSR Compliant client if you want to. This will be a BC break tho, so I guess we need to target a new branch like next instead of master?

GaryPEGEOT avatar Oct 24 '24 13:10 GaryPEGEOT

This can be shipped as a new major Elastically version. Can we make sure update the documentation as well?

damienalexandre avatar Oct 24 '24 13:10 damienalexandre

Done in https://github.com/jmariller/elastically/pull/1

GaryPEGEOT avatar Oct 24 '24 13:10 GaryPEGEOT

I'm creating a PR on damien's fork

Wouldn't it better to do it directly on this repo ?

VincentLanglet avatar Oct 24 '24 13:10 VincentLanglet

~~It would, but I had to fork jmariller fork to get his changes. Not sure if can make a PR from a fork of a fork~~ Nevermind, I created a separate PR

GaryPEGEOT avatar Oct 24 '24 13:10 GaryPEGEOT

I have some clean up to do before a release. For example we must remove OpenSearch from supported products :disappointed:

damienalexandre avatar Nov 13 '24 15:11 damienalexandre

Version 2.0 of Elastically, with Elastica 8, is now available! Thanks everyone!

damienalexandre avatar Nov 21 '24 22:11 damienalexandre