diff --git a/README.md b/README.md index dde7355..50d0b0e 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Main features: > [!IMPORTANT] > Require PHP 8.0+ and Elasticsearch 8+. -Works with **Elasticsearch 7** as well but is not officially supported by Elastica 8. Use with caution. +Works with **Elasticsearch 7** as well, but is not officially supported by Elastica 8. Use with caution. Version 2+ does not work with **OpenSearch** anymore due to restrictions added by Elastic on their client. @@ -249,7 +249,9 @@ Then configure the bundle: # config/packages/elastically.yaml elastically: connections: + # You can create multiple clients default: + # Any Elastica option works here client: hosts: - '127.0.0.1:9200' @@ -272,6 +274,10 @@ elastically: # If you want to add a prefix for your index in elasticsearch (you can still call it by its base name everywhere!) # prefix: '%kernel.environment%' + + # Use HttpClient component + transport_config: + http_client: 'Psr\Http\Client\ClientInterface' ``` Finally, inject one of those service (autowirable) in you code where you need @@ -340,8 +346,8 @@ JoliCode\Elastically\Client: $config: hosts: - '127.0.0.1:9200' - transport_client: - client: '@my_custom_psr18_client' # An instance of Symfony\Component\HttpClient\Psr18Client (Or any PSR 18 compliant one) + transport_config: + http_client: 'Psr\Http\Client\ClientInterface' ``` See the [official documentation on how to get a PSR-18 client](https://symfony.com/doc/current/http_client.html#psr-18-and-psr-17). @@ -440,7 +446,6 @@ $factory = new Factory([ - some "todo" in the code - optional Doctrine connector -- better logger - maybe via a processor? extending _log is supposed to be deprecated :( - extra commands to monitor, update mapping, reindex... Commonly implemented tasks - optional Symfony integration: - web debug toolbar! diff --git a/UPGRADE.md b/UPGRADE.md index 6a2248c..a820313 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,17 +2,16 @@ ## From v1.9.0 to v2.0.0 +> [!WARNING] +> All the deprecation from Elastica 7 to Elastica 8 apply to this major version, +> [see their UPGRADE first](https://github.com/ruflin/Elastica/blob/58042887616eeb63621412c03bc903056bbcee7e/UPGRADE-8.0.md#upgrade-from-73-to-80). + HttpClientTransport has been removed, you must replace it with [a PSR-18 client](https://symfony.com/doc/current/http_client.html#psr-18-and-psr-17): ```diff - JoliCode\Elastically\Client: - arguments: - $config: - host: '%env(ELASTICSEARCH_HOST)%' - port: '%env(ELASTICSEARCH_PORT)%' -- transport: '@JoliCode\Elastically\Transport\HttpClientTransport' -+ transport_client: -+ client: '@my_custom_psr18_client' # An instance of Symfony\Component\HttpClient\Psr18Client (Or any PSR 18 compliant one) +- transport: '@JoliCode\Elastically\Transport\HttpClientTransport' ++ transport_config: ++ http_client: 'Psr\Http\Client\ClientInterface' ``` Code has been cleaned of deprecations: @@ -37,7 +36,7 @@ Code has been cleaned of deprecations: - Removed `\JoliCode\Elastically\Client::getDenormalizer`, use the Factory (`\JoliCode\Elastically\Factory`) or DIC - Removed `\JoliCode\Elastically\Client::getSerializerContext`, use the Factory (`\JoliCode\Elastically\Factory`) or DIC - Using `\Elastica\Document::setData` to store your DTO will not work anymore, you must use `\JoliCode\Elastically\Model\Document` instead -- + ## From v1.3.0 to v1.4.0 If you're using Symfony, here are the changes to apply: diff --git a/src/Bridge/Symfony/DependencyInjection/Configuration.php b/src/Bridge/Symfony/DependencyInjection/Configuration.php index 63b5ee2..8fd0f0b 100644 --- a/src/Bridge/Symfony/DependencyInjection/Configuration.php +++ b/src/Bridge/Symfony/DependencyInjection/Configuration.php @@ -31,7 +31,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('client') ->info('All options for the Elastica client constructor') ->example([ - 'host' => '%env(ELASTICSEARCH_HOST)%', + 'hosts' => ['%env(ELASTICSEARCH_HOST)%', 'http://localhost:9200'], ]) ->normalizeKeys(false) ->defaultValue([])