jolicode / elastically

🔍 JoliCode's Elastica wrapper to bootstrap Elasticsearch PHP integrations
248 stars 37 forks source link

Upgrade guide from 1.3 to 1.4? #99

Closed jmsche closed 2 years ago

jmsche commented 2 years ago

Hi,

Could someone please write a guide about upgrading from 1.3 to 1.4?

I tried to upgrade last week (well, on a - very - large project), and had some trouble to do so, and maybe I'm not alone? :)

lyrixx commented 2 years ago

OH, this is not normal. only a change in the composer.json should be enough. However, I deprecated some things.

You can paste error here, and I'll try to help you

jmsche commented 2 years ago

It's in a Symfony project, so I had to change most YAML config.

I'll try to come back next week with the errors/issues I'll get :)

damienalexandre commented 2 years ago

Could you provide more insights about what we could improve in the documentation? Thanks!

jmsche commented 2 years ago

Hi Damien & Grégoire,

Sorry for the delay :)

Managed to do it, here is the result of the diff:

services:
    _defaults:
        autowire: true
        autoconfigure: true

+    JoliCode\Elastically\IndexNameMapper:
+        arguments:
+            $prefix: archi_%kernel.environment%
+            $indexClassMapping:
+                news: Generated\Model\News
+
+    JoliCode\Elastically\Serializer\StaticContextBuilder:
+        arguments:
+            $mapping: []
+
+    JoliCode\Elastically\ResultSetBuilder:
+        arguments:
+            $indexNameMapper: '@JoliCode\Elastically\IndexNameMapper'
+            $contextBuilder: '@JoliCode\Elastically\Serializer\StaticContextBuilder'
+            $denormalizer: '@serializer'

    JoliCode\Elastically\Client:
        arguments:
            $config:
                host: '%env(ELASTICSEARCH_HOST)%'
                port: '%env(ELASTICSEARCH_PORT)%'
                transport: '@JoliCode\Elastically\Transport\HttpClientTransport'
                elastically_mappings_directory: '%kernel.project_dir%/config/elasticsearch'
-                elastically_index_class_mapping:
-                    news: Generated\Model\News
-                elastically_serializer: '@serializer'
-                elastically_bulk_size: 100
                elastically_index_prefix: archi_%kernel.environment%
            $logger: '@logger'
+            $resultSetBuilder: '@JoliCode\Elastically\ResultSetBuilder'
+            $indexNameMapper: '@JoliCode\Elastically\IndexNameMapper'
+
+    JoliCode\Elastically\Indexer:
+        arguments:
+            $client: '@JoliCode\Elastically\Client'
+            $serializer: '@serializer'
+            $bulkMaxSize: 100
+            $bulkRequestParams: []
+            $contextBuilder: '@JoliCode\Elastically\Serializer\StaticContextBuilder'
+
+    JoliCode\Elastically\Mapping\YamlProvider:
+        arguments:
+            $configurationDirectory: '%kernel.project_dir%/config/elasticsearch'
+
+    JoliCode\Elastically\IndexBuilder:
+        arguments:
+            $mappingProvider: '@JoliCode\Elastically\Mapping\YamlProvider'
+            $client: '@JoliCode\Elastically\Client'
+            $indexNameMapper: '@JoliCode\Elastically\IndexNameMapper'

    JoliCode\Elastically\Transport\HttpClientTransport: ~
    JoliCode\Elastically\Messenger\IndexationRequestHandler: ~

    JoliCode\Elastically\Messenger\DocumentExchangerInterface:
        alias: App\Elasticsearch\DocumentExchanger

I don't recall using an upgrade guide (is there any?), so I made a diff from my config & the docs to apply it correctly. (Note: IIRC I upgraded from 1.3 to 1.5 directly when I managed to find the time to do it)

Do you think it would be worth creating an upgrade guide for this?

PS: I see there's a bridge planned for Symfony, can't wait :)

lyrixx commented 2 years ago

Hi, There is some help in the CHANGELOG

Do you think it would be worth creating an upgrade guide for this?

But indeed, a UPGRADE could be nice.

Do you want to give a try?

jmsche commented 2 years ago

I'll have a look on Monday :)

damienalexandre commented 2 years ago

Now available at https://github.com/jolicode/elastically/blob/master/UPGRADE.md <3