Move the schema initialization setting such as the "lifecycle.strategy" from Elasticsearch to the mapper
Expose an API to control the initialization programmatically, with more options such as reindexing.
Executing initialization on startup is not always a valid option, especially when multiple instances of the applications are deployed, or when Elasticsearch may not be reachable on startup (containers). So we need an API.
Schema initialization is almost always followed by reindexing, which can only be done at the mapper level. So it would be nice to have both in the same API.
For near-zero-downtime indexing, we will have to be able to temporarily create separate indexes and perform reindexing on these. So it will be necessary to mix the initialization API and mass indexing API.
In the future, we may have to take extra steps at the mapper level when initializing the application, for example dropping or creating Debezium connectors. This can only be handled at the mapper level.
The configuration options would probably be something like this:
As to the API, I would imagine something like this:
Or for near-zero-downtime indexing: