Skip to content

Magento 2 catalog search on OpenSearch

Learn how to set up and tune Magento OpenSearch catalog search on Magento 2.4. You will also be able to fix empty or stale search results as your catalog grows.

This guide shows Magento 2.4 store operators how to run catalog search on OpenSearch, the open-source engine that finds products when shoppers type a query. Since Magento 2.4.6, OpenSearch is the supported search backend, and Elasticsearch is no longer the recommended option.

Once a catalog grows past a few thousand products, you may see “No results found” for every query, or results that miss recent product changes. Empty results usually mean the search alias (the name Magento queries) points to an index (the stored copy of your product data) that no longer exists. Stale results usually mean the cron (the scheduled task runner) has stopped, so product updates pile up unprocessed. This guide shows you how to check both, tune the few settings that matter, and keep the index fresh.

How to verify

A healthy Magento+OpenSearch pair shows:

curl -s http://127.0.0.1:9200/_cat/indices/magento2_*?v
# health status index                          docs.count store.size
# green  open   magento2_product_1_v17         12480      82mb
# green  open   magento2_category_product_1_v3 348        1.1mb

bin/magento config:show catalog/search/engine
# opensearch

bin/magento indexer:status catalogsearch_fulltext
# Catalog Search                              | Ready

curl -s "http://127.0.0.1:9200/magento2_product_1_v17/_search?q=name:test&size=1" | jq '.hits.total'
# {"value": 4, "relation": "eq"}

If the active alias points at a missing index, the storefront returns “No results found” for everything until you reindex. The pattern below tells you who’s wrong.

curl -s http://127.0.0.1:9200/_alias | jq 'keys[] | select(startswith("magento2"))'
curl -s http://127.0.0.1:9200/magento2_product_1/_alias
# expect: { "magento2_product_1_v17": { "aliases": { "magento2_product_1": {} } } }

What’s happening

Magento writes documents to OpenSearch under indexes named magento2_<entity>_<store_id>_v<n>. The _v<n> suffix is an internal version counter incremented on each full reindex; the unversioned alias (magento2_product_1) is what Magento queries. A reindex builds the next version, swaps the alias atomically, then deletes the old version — that’s why a half-failed reindex leaves orphan indexes behind.

The mappings are generated dynamically based on your catalog attributes. Anything with “Used in Search” enabled in Stores > Attributes > Product gets indexed, and the search weight in that screen becomes the boost on the field at query time. There is no separate analyzer config in the Magento admin — the engine uses OpenSearch’s default analyzer plus per-language stop words pulled from app/code/Magento/Elasticsearch/etc/stopwords.csv (still named after Elasticsearch internally). For French Canadian stores, you should publish a custom fr_CA stopword list or you’ll match “le”, “la”, “des” in every query.

Indexer modes matter. The catalogsearch_fulltext indexer can run “Update on Save” (slow, fine for dev) or “Update on Schedule” (mandatory in production). On schedule, the changelog table catalogsearch_fulltext_cl accumulates row ids, and the cron consumer processes them every minute. If the cron is broken, that table grows without bound and the storefront index ages — which is the most common cause of “stale search” reports.

The procedure

  1. Pin Magento to OpenSearch.

    bin/magento config:set catalog/search/engine opensearch
    bin/magento config:set catalog/search/opensearch_server_hostname 127.0.0.1
    bin/magento config:set catalog/search/opensearch_server_port 9200
    bin/magento config:set catalog/search/opensearch_index_prefix magento2
    bin/magento cache:clean config
  2. Set the indexer to schedule.

    bin/magento indexer:set-mode schedule catalogsearch_fulltext

    Verify the cron group index runs every minute in your crontab. If you do not see bin/magento cron:run --group=index firing, fix that first.

  3. Tune the refresh interval per index template. Default refresh is 1s — fine on small catalogs, expensive on 100k+ products. Drop a template:

    curl -X PUT http://127.0.0.1:9200/_index_template/magento_catalog -H 'Content-Type: application/json' -d '{
      "index_patterns": ["magento2_product_*"],
      "template": { "settings": { "index.refresh_interval": "5s", "number_of_shards": 1, "number_of_replicas": 1 } }
    }'

    New reindexes inherit these settings; existing indexes are unchanged until the next full reindex.

  4. Curate stopwords per locale. Edit app/code/Magento/Elasticsearch/etc/stopwords_fr_ca.csv (or override via di.xml in a custom module) and add the Quebec stop words your catalog needs. Then full-reindex:

    bin/magento indexer:reindex catalogsearch_fulltext
  5. Verify attribute weights. In Stores > Attributes > Product > [attribute] > Storefront Properties, set “Search Weight” between 1 and 10. name typically 8, sku 6, description 1. Verify the boost is reflected in OpenSearch:

    curl -s http://127.0.0.1:9200/magento2_product_1/_mapping | jq '.[].mappings.properties.name'
    # { "type": "text", "boost": 8.0 }

    Note: boost in mappings is deprecated in OpenSearch 2.x — Magento applies the weight at query time instead. The mapping is informational.

  6. Monitor the changelog backlog. Add a check that runs every five minutes:

    bin/magento dev:query-log:enable
    mysql -h127.0.0.1 -umagento -p magento -e \
      "SELECT COUNT(*) FROM catalogsearch_fulltext_cl;"

    Alert if the count exceeds your normal product-save rate by 10x. Investigation usually finds a broken cron or an exception thrown by a third-party module’s indexer plugin.

  7. Reindex on a schedule of your choice — not automatically. Many teams do a full reindex nightly to catch drift; that’s a bin/magento indexer:reindex from a maintenance window or a cron at 03:00, not on every release. A full reindex on a 50k-product catalog takes 2-10 minutes; the alias swap is atomic so the storefront does not blink.

Operational notes

  • Orphan indexes from failed reindexes are silent disk eaters. Run curl /_cat/indices/magento2_* weekly and remove any version older than the one in the active alias.
  • OpenSearch with the security plugin enabled needs the admin credentials in app/etc/env.php under system.default.catalog.search.opensearch_username and opensearch_password — many teams leave this off in dev and wonder why prod returns empty results.
  • The “Suggested terms” feature uses a separate index built on _search/suggest — broken suggestions usually mean the suggester component was disabled in the engine config.
  • A heap of mongoexport or mysqldump running on the same host steals page cache from OpenSearch — keep OpenSearch on its own box once you cross ~50k products, or pin its memory aggressively.
  • After a Magento upgrade, the index version often jumps by one even if no mappings changed — that’s by design, so the upgrade has a clean rollback path. Plan disk for two copies of the catalog.

For Magento stores where merchandisers expect typo-tolerant, fast search at scale, Stack Harbor operates the OpenSearch cluster alongside Magento — index lifecycle scripted, changelog backlog alerted, custom stopwords versioned, full reindex on a maintenance schedule — so the catalog team can iterate on attributes without thinking about the engine. That model lives under managed operations, and the related Magento 2 install runbook walks through the first-time setup.