elasticsuite icon indicating copy to clipboard operation
elasticsuite copied to clipboard

Fatal Error: Class Elasticsearch\ClientBuilder does not exist when using elasticsearch/elasticsearch version ~8.5.0

Open jsamhall opened this issue 1 year ago • 7 comments

Attempting to execute bin/magento results in a fatal error, breaking functionality. This appears to be due to a change in elasticsearch/elasticsearch package namespaces starting at version 8.x that is not accounted for in smile/module-elasticsuite-core

Note The installation literature for Magento 2.4.6 using ES version 8.x states to ensure Magento's ES8 module is installed: image

This module calls for elasticsearch/elasticsearch ~8.5.0: image

The following shows the breaking difference in package namespaces that results in the error described here:

File: vendor/elasticsearch/elasticsearch/src/ClientBuilder.php Note: the FQCN is Elastic\Elasticsearch\ClientBuilder image

File: vendor/smile/elasticsuite/src/module-elasticsuite-core/Client/ClientBuilder.php Note: The ES package ClientBuilder has an incorrect FQCN; the Elastic namespace is absent and not imported

File head: image

Class constructor: image

Preconditions

Ubuntu 20.04 LTS

Magento Version : 2.4.6

ElasticSuite Version : 2.11.0

Environment : Either

Third party modules : Very few, unrelated Relevant modules is : elasticsearch/elasticsearch 8.5.3

Steps to reproduce

Install Magento 2.4.6 -- Ensure elasticsearch/elasticsearch package 8.5.x is installed Install smile/elasticsuite 2.11.0 Attempt to execute bin/magento

Expected result

The Magento CLI binary should output available commands

Actual result

The output crashes due to a constructor impossibility: image

jsamhall avatar Mar 24 '23 16:03 jsamhall

Hi @jsamhall

  • you don't need to do composer require magento/module-elasticsearch-8 --update-with-all-dependencies for using Elasticsuite

  • but yes, you're right, it seems we have an issue when enforcing the elasticsearch/elasticsearch package to 8.5.3

==> we'll try to have a BC fix for this, since our goal is to support both ES7 and ES8.

  • that being said, you can run ES8 without issues while having the elasticsearch/elasticsearch package in version 7.

Regards

romainruaud avatar Mar 24 '23 16:03 romainruaud

Thank you for the quick response @romainruaud

I noticed there are only a couple references to the deprecated namespace and seem to be only in Smile's core so I hope it is not too big of a refactor for the Smile team!

I will revert back to elasticsearch/elasticsearch version 7.11.x for the time being!

jsamhall avatar Mar 24 '23 16:03 jsamhall

#2910 contains the beginning of my work.

However, there's a lot more to refactor than what I initally thought....

Stay tuned, but keep using client v7 for now :)

romainruaud avatar Apr 14 '23 12:04 romainruaud

@romainruaud Any rough ideas on an ETA for the fix. Was really disappointed to see this error when trying to install when using Elasticsearch 8.4.3

chrisbadley avatar Apr 17 '23 06:04 chrisbadley

Until this is resolved, would it be wise to remove "8.x" from the README under elasticsearch on the version table? For us at least, we had the same issue and then some. In addition to removing the Elasticsearch 8 Magento module, Elasticsearch 8.x had to be entirely purged from the system and replaced with 7.x in order for Elasticsuite to function.

ZandaBear avatar Dec 24 '23 01:12 ZandaBear

@ZandaBear : Elasticsearch8 is fully supported, you just don't need to use the Elasticsearch8 Magento module.

Regards

romainruaud avatar Jan 02 '24 09:01 romainruaud

@romainruaud Hmmm, that is very interesting as our site was completely non-functional until we purged elasticsearch 8 and installed 7. With 8, the very moment we introduced a non-default product attribute set categories would randomly and irreversibly appear empty, searches would have no results on the page (though you could click on a product that appeared in the search field successfully), invalid and undefined index errors galore, etc. All issues disappeared the moment we did the downgrade, no other settings or configs changed.

ZandaBear avatar Jan 02 '24 18:01 ZandaBear

This has been fixed and Elasticsearch 8 is fully supported.

There is still no need to install the magento-elasticsearch-8 module, but installing it is not causing anymore errors.

romainruaud avatar Aug 02 '24 12:08 romainruaud