Magento and Elasticsearch: local catalog search works but production search fails
28K reputation · 12 Aug 2023, 11:03 UTC
On a Magento 2.4.x store, the catalog search engine is set under Stores > Configuration > Catalog > Catalog Search, and locally the default engine was left as MySQL full-text. In production, the plan is to use a remote Elasticsearch/OpenSearch cluster, but the local MySQL-based setup passes every storefront search and category filter test, while the production deployment shows empty results or a broken catalogsearch_fulltext index. The same code and the same admin configuration path should provide the same result, but they do not. Is the failure caused by Magento configuration, the search service, or the boundary between the two?
Catalog search can be configured in the Admin or in app/etc/env.php, and the engine setting can differ between environments. The catalogsearch_fulltext index can also be out of date or point to a different index prefix. The index can be rebuilt, but result sets, layered navigation, and relevance can differ between MySQL full-text and Elasticsearch/OpenSearch. Should production search behavior be treated as application configuration or as an infrastructure contract? Which logs and checks can separate Magento errors from backend connectivity errors? And when switching engines, which values must be compared between local and production to confirm they resolve to the same backend?