«Class "Elasticsearch\ClientBuilder" not found» in Magento 2.4.6 and 2.4.7-beta1


1. The class Elasticsearch\ClientBuilder exists in elasticsearch/elasticsearch < 8

2. The class Elasticsearch\ClientBuilder does not exist in elasticsearch/elasticsearch ≥ 8

3. Magento 2.4.6 and 2.4.7-beta1 require elasticsearch/elasticsearch 7.17 or 8.5:

4. Magento 2.4.6 and 2.4.7-beta1 include the Magento_Elasticsearch7 module:

5. The Magento_Elasticsearch7 module in Magento 2.4.6 and 2.4.7-beta1 references the Elasticsearch\ClientBuilder class:

Step 1

Remove the line:

Step 2

composer2 require magento/module-elasticsearch-8 --update-with-all-dependencies


Step 3

bin/magento module:enable Magento_Elasticsearch8

Step 4

bin/magento setup:upgrade
bin/magento cache:enable
rm -rf var/di var/generation generated/*
bin/magento setup:di:compile
rm -rf pub/static/*
bin/magento setup:static-content:deploy -f en_US <additional locales>

Step 5

bin/magento config:set catalog/search/engine elasticsearch8
bin/magento config:set catalog/search/elasticsearch8_index_prefix <your value>
bin/magento cache:clean

Step 6

bin/magento indexer:reindex
bin/magento cron:run --bootstrap=standaloneProcessStarted=1
bin/magento cache:clean