We need to setup elasticsearch on Magento 2 when a new container starts. We have post-install scripts that could handle that and not have someone go into the admin and manually do it.
Thanks.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityWe need to setup elasticsearch on Magento 2 when a new container starts. We have post-install scripts that could handle that and not have someone go into the admin and manually do it.
Thanks.
Found a way to do it. We added these commands to our post-install script:
magento config:set catalog/search/engine 'elasticsearch5'
magento config:set catalog/search/elasticsearch5_server_hostname 'elasticsearch-hostname.env'
You can also configure other things like ports:
magento config:set catalog/search/elasticsearch5_server_port '9200'
magento config:set catalog/search/elasticsearch5_index_prefix 'magento2'
magento config:set catalog/search/elasticsearch5_enable_auth '0'
magento config:set catalog/search/elasticsearch5_server_timeout '15'
These are the engine options:
mysql - MySQL
elasticsearch - Elasticsearch
elasticsearch5 - Elasticsearch5.0+
If you decide to use variables on the server_hostname, you must use double quotes:
magento config:set catalog/search/elasticsearch5_server_hostname "elasticsearch-$MY_VARIABLE.env"
catalog/search/engine
and catalog/search/elasticsearch5_server_hostname
?
Oct 19, 2020 at 23:30
<engine>elasticsearch7</engine>
Oct 21, 2020 at 2:20