Search engine configuration

This section discusses the minimum settings that you must choose to test Elasticsearch or OpenSearch with on-premises deployments of Adobe Commerce.

TIP
In versions 2.4.4 and 2.4.3-p2, all fields labeled Elasticsearch also apply to OpenSearch.
When support for Elasticsearch 8.x was introduced in version 2.4.6, new labels were created to distinguish between Elasticsearch and OpenSearch configurations.

For additional details about configuring your search engine, see the User Guide.

Configure your search engine from the Admin

TIP
For instructions on upgrading to a new search engine version, see upgrade prerequisites.

To configure your system to use Elasticsearch or OpenSearch:

  1. Log in to the Admin as an administrator.

  2. Click Stores > Settings > Configuration > Catalog > Catalog > Catalog Search.

  3. From the Search Engine list, select the corresponding version of your search engine.

    The following table lists the required options to configure and test the connection with Commerce. Unless you changed the server settings of your search engine, the defaults should work. Skip to the next step.

    table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 5-row-2
    Option Description
    Server Hostname Enter the fully qualified hostname or IP address of the machine running Elasticsearch or OpenSearch.
    Adobe Commerce on cloud infrastructure: Get this value from your integration system.
    Server Port Enter the web server proxy port. The default is 9200
    Adobe Commerce on cloud infrastructure: Get this value from your integration system.
    Index Prefix Enter the search engine index prefix. If you use a single instance for more than one Commerce installation (Staging and Production environments), you must specify a unique prefix for each installation. Otherwise, you can use the default prefix magento2.
    Enable HTTP Auth Click Yes only if you enabled authentication for your search engine server. If so, provide a username and password in the provided fields.
    Server Timeout Enter the amount of time (in seconds) to wait when attempting to establish a connection to the Elasticsearch or OpenSearch server.
  4. Click Test Connection.

    Sample response:

    success

    Continue with:

    or you see:

    failed

If so, try the following:

  • Make sure the search engine server is running.

  • If the server is on a different host from Commerce, log in to the Commerce server and ping the search engine host. Resolve network connectivity issues and test the connection again.

  • Examine the command window in which you started Elasticsearch or OpenSearch for stack traces and exceptions. You must resolve those before you continue. In particular, make sure you started your search engine as a user with root privileges.

  • Make sure that UNIX firewall and SELinux are both disabled, or set up rules to enable your search engine and Commerce to communicate with each other.

  • Verify the value of the Server Hostname field. Make sure that the server is available. You can try the server’s IP address instead.

  • Use the netstat -an | grep <listen-port> command to verify that the port specified in the Server Port field is not being used by another process.

    For example, to see if your search engine is running on its default port, use the following command:

    code language-bash
    netstat -an | grep 9200
    

    If it is running on port 9200, it displays similar to the following:

    code language-none
    `tcp        0      0 :::9200            :::-         LISTEN`
    

Reindex catalog search and refresh the full page cache

After you change the search engine configuration, you must reindex the catalog search index and refresh the full page cache using the Admin or command line.

To refresh the cache using the Admin:

  1. In the Admin, click System > Cache Management.

  2. Select the checkbox next to Page Cache.

  3. From the Actions list in the upper right, click Refresh.

    cache management

To clean the cache using the command line: bin/magento cache:clean

To reindex using the command line:

  1. Log in to your Commerce server as, or switch to, the file system owner.

  2. Enter any of the following commands:

    Enter the following command to reindex the catalog search index only:

    code language-bash
    bin/magento indexer:reindex catalogsearch_fulltext
    

    Enter the following command to reindex all indexers:

    code language-bash
    bin/magento indexer:reindex
    
  3. Wait until reindexing completes.

    note info
    INFO
    Unlike the cache, indexers are updated by a cron job. Make sure cron is enabled before you start using your search engine.
recommendation-more-help
386822bd-e32c-40a8-81c2-ed90ad1e198c