初めに
サンプルデータを入れるためにあえて古いバージョンを入れたMagentoですが、V2.3.5では検索エンジンがMySqlでした。これをElasticSearchに変更します。
/etc/elasticsearch/elasticsearch.ymlの編集
赤線部分(clust
)をnode.name
で定義した My First Node に変更します。
その後、elasticsearchを再起動します。ちなみにelasticsearchのログは/var/log/elasticsearch/
の下にあります。
sudo systemctl daemon-reload
sudo systemctl restart elasticsearch.service
Magento側の設定変更
エンジンの設定はStores - Configuration - Catalog - Catalog Search
の中にあります。
Use system value
のチェックを外しElasticsearchを選択します。
このボタンで接続確認を行います。
以下の表示が出れば接続確認OKです。
Save Config
します。
これだけだと何も出力されないので、キャッシュとインデックスを作り直します。
$ bin/magento indexer:reindex
Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:00
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Product EAV index has been rebuilt successfully in 00:00:01
Stock index has been rebuilt successfully in 00:00:00
Inventory index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:01
Google Product Removal Feed index has been rebuilt successfully in 00:00:00
Google Product Feed index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:02
$ bin/magento cache:flush
Flushed cache types:
config
layout
block_html
collections
reflection
db_ddl
compiled_config
eav
customer_notification
config_integration
config_integration_api
google_product
full_page
config_webservice
translate
vertex
おしまい。