Shopware - Setup of OpenSearch
This article describes how to integrate OpenSearch into Shopware 6 to improve your search results and performance and how to carry out initial indexing.
Prerequisites
- Shopware installation / server (Shopware 6.5.X or higher)
- OpenSearch server
- Authorization configuration module Customer Center
Preparation OpenSearch server
Create a VPC network and add an additional network card with an IP address from the VPC network to your OpenSearch server.
Open the OpenSearch server configuration file opensearch.yml via the Configuration module of the Customer Center to prepare the connection to Shopware via VPC network.
To do this, change the following settings or add them if they do not already exist and save them so that the changed configuration is transferred to the server and becomes active:
default setting | new / additional setting | description |
---|---|---|
#cluster.name: my-application | cluster.name: shopware | cluster name |
#node.name: node-1 | node.name: XXXXX | server name |
-\n(not available by default) | http.bind_host: ["127.0.0.1", "10.20.0.X"] | IP addresses to which the OpenSearch server provides the service. In this case, the service is only provided locally on the server and for the VPC IP address. |
#cluster.initial_cluster_manager_nodes: ["node-1", "node-2"] | cluster.initial_cluster_manager_nodes: ["XXXXX.creolineserver.com"] | cluster nodes |
plugins.security.ssl.http.enabled: true | plugins.security.ssl.http.enabled: false | Disable enforced SSL/TLS for the REST API. When using our OpenSearch pre-installation, this option is already preconfigured. |
-(not available by default) | plugins.security.ssl_only: false | Generally disables forced SSL/TLS.when using our OpenSearch pre-installation, this option is already pre-configured. |
Configuration Shopware frontend
To connect OpenSearch to Shopware, you must first enter the following connection information and general settings in the .env.local
configuration file of your Shopware installation. You can find the access data in the password vault of your OpenSearch server:
OPENSEARCH_URL=http://admin:<password>@10.20.0.X
SHOPWARE_ES_ENABLED="1"
SHOPWARE_ES_INDEXING_ENABLED="1"
SHOPWARE_ES_INDEX_PREFIX="<prefix name>"
In the next step, create the following configuration file:
nano /var/www/vhosts/<DocumentRoot>/httpdocs/config/packages/elasticsearch.yml
Insert the following content when using a single OpenSearch server:
elasticsearch:
hosts: "%env(string:OPENSEARCH_URL)%"
index_settings:
number_of_shards: 1
number_of_replicas: 0
Then clear the Shopware cache as follows so that the changed configuration becomes active:
bin/console cache:clear
perform initial front-end indexing
If you have already used OpenSearch or Elasticsearch in the past, we recommend removing all old indexes and associated settings that are no longer required from Shopware using the following commands before generating a new index:
bin/console es:index:cleanup (remove all indexes that are no longer used)
bin/console es:reset (Reset all OpenSearch / Elasticsearch indexes)
Then completely rebuild the index:
bin/console dal:refresh:index (Rebuild entire index)
The complete re-generation of the index can take a long time depending on the number of products, media etc.. It may also be necessary to increase the PHP memory limit so that the process can be completed.
It may be necessary to generate aliases if certain products are not found:
bin/console es:create:alias
If you use various plugins that may influence the search in Shopware, set up custom fields or similar for products, etc., you may need to make adjustments so that the indexing achieves the desired result. Depending on the Shopware version used, there may be additional deviations.
Configuration Shopware Administration
You can also use OpenSearch for indexing the administration. To do this, expand your .env.local
as follows:
# OpenSearch Admin Configuration
ADMIN_OPENSEARCH_URL=http://admin:<password>@10.20.0.X
SHOPWARE_ADMIN_ES_ENABLED=1
SHOPWARE_ADMIN_ES_REFRESH_INDICES=1
SHOPWARE_ADMIN_ES_INDEX_PREFIX="admin_test"
Then clear the Shopware cache as follows so that the changed configuration becomes active:
bin/console cache:clear
initial administration indexing
If you have already used OpenSearch or Elasticsearch in the past, we recommend removing all old indexes and associated settings that are no longer required from Shopware using the following commands before generating a new index:
bin/console es:admin:reset (Reset all OpenSearch / Elasticsearch indexes)
Then completely rebuild the index:
bin/console es:admin:index (create index for the administration)
The complete re-generation of the index can take a long time depending on the number of products, media etc.. It may also be necessary to increase the PHP memory limit so that the process can be completed.
Please also note that the use of plugins or individual search settings can strongly influence the actual results. Depending on the Shopware version used, there may be additional deviations.