Elastica: ruflin/elastica 6.x is not compatible with elasticsearch/elasticsearch-php 6.8.0

Downstream task: https://phabricator.wikimedia.org/T276320

6.x of ruflin/elastica as per https://github.com/ruflin/Elastica/blob/6.x/composer.json#L17 supports "elasticsearch/elasticsearch": "^6.0"

However, trying to use 6.x of ruflin/elastica with 6.8 of elasticsearch/elasticsearch causes errors due to https://github.com/ruflin/Elastica/blob/6.x/lib/Elastica/Index.php#L451

[3e8bfb9228c410ca976223cf] [no req]   Error from line 451 of /var/www/html/vendor/ruflin/elastica/lib/Elastica/Index.php: Class 'Elasticsearch\Endpoints\Indices\Aliases\Update' not found
Backtrace:
#0 /var/www/html/extensions/CirrusSearch/includes/Maintenance/Validators/SpecificAliasValidator.php(137): Elastica\Index->addAlias(string, boolean)
#1 /var/www/html/extensions/CirrusSearch/includes/Maintenance/Validators/SpecificAliasValidator.php(79): CirrusSearch\Maintenance\Validators\SpecificAliasValidator->updateFreeIndices(array)
#2 /var/www/html/extensions/CirrusSearch/includes/Maintenance/Validators/IndexAliasValidator.php(98): CirrusSearch\Maintenance\Validators\SpecificAliasValidator->updateIndices(array, array)
#3 /var/www/html/extensions/CirrusSearch/maintenance/UpdateOneSearchIndexConfig.php(458): CirrusSearch\Maintenance\Validators\IndexAliasValidator->validate()
#4 /var/www/html/extensions/CirrusSearch/maintenance/UpdateOneSearchIndexConfig.php(411): CirrusSearch\Maintenance\UpdateOneSearchIndexConfig->validateSpecificAlias()
#5 /var/www/html/extensions/CirrusSearch/maintenance/UpdateOneSearchIndexConfig.php(269): CirrusSearch\Maintenance\UpdateOneSearchIndexConfig->validateAlias()
#6 /var/www/html/extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php(61): CirrusSearch\Maintenance\UpdateOneSearchIndexConfig->execute()
#7 /var/www/html/maintenance/doMaintenance.php(107): CirrusSearch\Maintenance\UpdateSearchIndexConfig->execute()
#8 /var/www/html/extensions/CirrusSearch/maintenance/UpdateSearchIndexConfig.php(70): require_once(string)
#9 {main}

If we look at https://github.com/elastic/elasticsearch-php/blob/6.7.x/src/Elasticsearch/Endpoints/Indices/Aliases/Update.php it still exists in 6.7, but in https://github.com/elastic/elasticsearch-php/blob/6.8.x/src/Elasticsearch/Endpoints/Indices/Aliases/Update.php it does not.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I just sent this PR to fix the issue https://github.com/elastic/elasticsearch-php/pull/1114.

@ruflin I released elasticsearch-php 6.8.0 including the support of PHP 8 and all the XPack endpoints. In order to accomplish this I used the new code generator used in 7.x branch.

elasticsarch-php < 6.8 contained some endpoints that do not exist in Elasticsearch 6. Moreover, the naming were not aligned with the API specification.

To resolve these issues, I used an alias approach with src/autoload.php to prevent BC breaks. Evidently, some alias was missed.

Here a list of issues provided by @reedy (https://github.com/elastic/elasticsearch-php/commit/2da5f9337a269113954a84fe8e79ea6843f0e7c3#commitcomment-47975845):

  • src/Elasticsearch/Endpoints/Cluster/Nodes/AbstractNodesEndpoint.php This class has been removed since the new code generator did not use it.

  • src/Elasticsearch/Endpoints/CountPercolate.php This endpoint does not exist in Elasticsearch 6. It was present in the PHP client <= 6.7 but it was a typo. This happened because the endpoints was manually maintained in the 6.x branch.

  • src/Elasticsearch/Endpoints/Indices/Aliases/Update.php This is a missing alias.

  • src/Elasticsearch/Endpoints/Indices/Exists/Types.php This is a missing alias. Actually, there is an alias ‘\Elasticsearch\Endpoints\Indices\Type\Exists’.

  • src/Elasticsearch/Endpoints/Indices/Field/Get.php This is a missing alias. The Elaticsearch 6 endpoint is named indices.get_field_mapping so the endpoint in 6.8.0 is src/Elasticsearch/Endpoints/Indices/GetFieldMapping.php.

  • src/Elasticsearch/Endpoints/Indices/Mapping/Delete.php This endpoint does not exist in Elasticsearch 6. It was present in the PHP client <= 6.7 but it was a typo. This happened because the endpoints was manually maintained in the 6.x branch.

  • src/Elasticsearch/Endpoints/Indices/Mapping/Put.php This endpoint is already in src/autoload.php.

  • src/Elasticsearch/Endpoints/MPercolate.php This endpoint does not exist in Elasticsearch 6. It was present in the PHP client <= 6.7 but it was a typo. This happened because the endpoints was manually maintained in the 6.x branch.

  • src/Elasticsearch/Endpoints/Percolate.php This endpoint does not exist in Elasticsearch 6. It was present in the PHP client <= 6.7 but it was a typo. This happened because the endpoints was manually maintained in the 6.x branch.

To summarize, the missing aliases are:

  • Elasticsearch\Endpoints\Indices\Aliases\Update
  • Elasticsearch\Endpoints\Indices\Exists\Types
  • Elasticsearch\Endpoints\Indices\Field\Get

I can fix this and release 6.8.1 soon. Let me know if there are other issues that I didn’t count. Thanks!