Magento 2 troubleshooting › Search
Why is Magento 2 search not working?
Short answer: Magento 2.4 search runs on OpenSearch (or Elasticsearch on older 2.4 versions). When search breaks for everything, the search server or its index is the cause. When only some products are missing, it's their visibility, status or website, or the index is behind.
If every search shows an error page or nothing at all, start with the connection. If search works but a product isn't found, start with the product.
Check it step by step
These queries only read data. Run them on a copy of your database if you can, or ask your developer to. If your tables have a prefix (set in app/etc/env.php), add it to each table name.
1. Which search engine and host Magento uses
Works on Magento Open Source and Adobe Commerce:
SELECT path, scope, scope_id, value
FROM core_config_data
WHERE path LIKE 'catalog/search/%'
ORDER BY path;
No row means the default from app/etc/env.php or config.php is used. The host and port must be reachable from the web server, not just from your laptop.
2. Is the search index valid and up to date?
Works on Magento Open Source and Adobe Commerce:
SELECT i.indexer_id, i.status, i.updated, m.mode, m.status AS schedule_status, m.version_id
FROM indexer_state i
LEFT JOIN mview_state m ON m.view_id = i.indexer_id
WHERE i.indexer_id = 'catalogsearch_fulltext';
invalid or working for a long time means the index needs a rebuild; see indexer stuck.
3. Can this product be found at all?
Only visibility 3 (Search) and 4 (Catalog, Search) are searchable, and the product must be enabled in that store view.
Magento Open Source
SET @sku = 'ABC-123'; -- your SKU
SELECT a.attribute_code, v.store_id, v.value
FROM catalog_product_entity e
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_product'
JOIN eav_attribute a_status ON a_status.entity_type_id = t.entity_type_id AND a_status.attribute_code = 'status'
JOIN eav_attribute a_visibility ON a_visibility.entity_type_id = t.entity_type_id AND a_visibility.attribute_code = 'visibility'
JOIN catalog_product_entity_int v ON v.entity_id = e.entity_id AND v.attribute_id IN (a_status.attribute_id, a_visibility.attribute_id)
JOIN eav_attribute a ON a.attribute_id = v.attribute_id
WHERE e.sku = @sku
ORDER BY a.attribute_code, v.store_id;
Adobe Commerce
Product, category, rule and CMS values are stored per version and joined on row_id (why):
SET @sku = 'ABC-123'; -- your SKU
SELECT a.attribute_code, v.store_id, v.value
FROM catalog_product_entity e
JOIN eav_entity_type t ON t.entity_type_code = 'catalog_product'
JOIN eav_attribute a_status ON a_status.entity_type_id = t.entity_type_id AND a_status.attribute_code = 'status'
JOIN eav_attribute a_visibility ON a_visibility.entity_type_id = t.entity_type_id AND a_visibility.attribute_code = 'visibility'
JOIN catalog_product_entity_int v ON v.row_id = e.row_id AND v.attribute_id IN (a_status.attribute_id, a_visibility.attribute_id)
JOIN eav_attribute a ON a.attribute_id = v.attribute_id
WHERE e.sku = @sku
AND e.created_in <= UNIX_TIMESTAMP() AND e.updated_in > UNIX_TIMESTAMP()
ORDER BY a.attribute_code, v.store_id;
4. What customers searched for and found nothing
Works on Magento Open Source and Adobe Commerce:
SELECT query_text, store_id, num_results, popularity, updated_at
FROM search_query
WHERE num_results = 0
ORDER BY popularity DESC
LIMIT 50;
These are your missing products, missing synonyms and spelling variants. Add synonyms in Marketing › SEO & Search › Search Synonyms.
How to fix it
- Test the connection in Stores › Configuration › Catalog › Catalog › Catalog Search › Test Connection. “No alive nodes found in your cluster” means Magento can't reach the search server: check it's running and the host, port and credentials.
- Rebuild the index:
bin/magento indexer:reindex catalogsearch_fulltext bin/magento cache:flush - Searches shorter than Minimal Query Length (3 by default, same configuration section) return nothing.
Good to know
- After a Magento upgrade, check the search engine version is one your Magento version supports; an unsupported version often fails quietly.