Magento SKU: Troubleshooting Elasticsearch Indexing
Magento SKU indexing issues can disrupt search results. Fix Elasticsearch errors with key troubleshooting steps for better performance.
magento sku
19425
wp-singular,post-template-default,single,single-post,postid-19425,single-format-standard,wp-custom-logo,wp-theme-burst,theme-burst,mkd-core-2.1.2,woocommerce-no-js,ajax_fade,page_not_loaded,,burst-ver-3.5, vertical_menu_with_scroll,smooth_scroll,woocommerce_installed,blog_installed,wpb-js-composer js-comp-ver-6.9.0,vc_responsive,elementor-default,elementor-template-full-width,elementor-kit-11943,elementor-page elementor-page-19425,elementor-page-12697

Magento SKU: Troubleshooting Elasticsearch Indexing

magento sku

If you’ve ever scratched your head wondering, “Why isn’t my SKU showing up in Magento 2 search?” you’re not alone. Magento’s search functionality, powered by Elasticsearch, can be a bit tricky, especially when it comes to SKU-related search issues. But don’t worry—I’ve got you covered with a friendly, expert guide to troubleshoot and fix this problem.

Understanding the Basics: How Magento SKU Search Works

Before diving into troubleshooting, let’s get the basics straight. Magento uses Elasticsearch as its default search engine from version 2.4 onwards. Elasticsearch indexes product data, including SKUs, to deliver fast and relevant search results.

A SKU (Stock Keeping Unit) is a unique identifier for each product. Magento allows customers to search for products using SKUs, but sometimes, even though a SKU exists, it doesn’t show up in search results. Why? It usually comes down to indexing issues, configuration mishaps, or Elasticsearch quirks.

what is reindexing in magento

Common Reasons Why SKUs Don’t Appear in Magento 2 Search

1. SKU Attribute Is Not Set as Searchable

One of the most common culprits is that the SKU attribute isn’t configured correctly.

How to Check:

  • Go to Stores > Attributes > Product.
  • Search for the SKU attribute.
  • Under Storefront Properties, ensure that “Use in Search” is set to Yes.

If this is set to No, Magento won’t include SKUs in search queries, even though the products exist.

2. Elasticsearch Indexing Issues

Magento relies heavily on Elasticsearch indexes to deliver search results. If the indexes are outdated or corrupted, SKUs may not appear.

How to Fix:

  1. Reindex Magento:
				
					php bin/magento indexer:reindex
				
			

2. Clear cache:

				
					php bin/magento cache:clean
php bin/magento cache:flush
				
			

3. Test the search again.

				
					php bin/magento indexer:status
				
			

Check the status of indexes using:

If an index is showing as “Reindex required,” that’s your red flag.

3. Elasticsearch Configuration Problems

Magento’s search relies on the Elasticsearch server configuration. A misconfiguration can lead to incomplete or missing search results.

What to Check:

  • Elasticsearch Version Compatibility: Make sure your Magento version supports the Elasticsearch version installed.
  • Elasticsearch Connection Settings: Go to Stores > Configuration > Catalog > Catalog Search and verify the Elasticsearch server settings.
  • Test Connection: Use the “Test Connection” button to confirm Magento can communicate with Elasticsearch.

If the connection fails, that’s a sign the search index isn’t being updated correctly.

4. Issues with Hyphens, Spaces, or Special Characters in SKUs

Sometimes, SKUs containing hyphens, spaces, or special characters don’t behave as expected in search queries. This happens because Elasticsearch tokenizes data differently, treating hyphens as word delimiters.

How to Address This:

  • Adjust Elasticsearch Analyzers: Modify the tokenizer and analyzer settings in Elasticsearch to handle special characters more effectively.
  • Add a Custom Synonym Filter: This can help Magento understand that “123-456” and “123456” might refer to the same SKU.

Example:

If you have SKUs like ABC-123 and 123-ABC, searching for “123” might miss one of them unless the tokenizer is configured to recognize hyphens correctly.

5. Product Visibility Settings

Even if everything else is configured correctly, your SKU won’t show up in search if the product’s visibility settings are incorrect.

How to Check:

  • Go to Catalog > Products.
  • Edit the product that isn’t appearing in search.
  • Ensure Visibility is set to either:
    • Catalog, Search (Best option)
    • Search (If you don’t want it visible in category pages)

If the visibility is set to “Not Visible Individually,” the product won’t appear in search results.

6. Outdated Product Cache or Flat Catalog Issues

Magento’s product cache and flat catalog settings can sometimes cause SKUs to disappear from search results.

Fix It By:

  • Disabling the flat catalog (Magento 2.3+ doesn’t rely on it heavily, but it could still cause issues):
    • Go to Stores > Configuration > Catalog > Catalog > Storefront.
    • Set Use Flat Catalog Product to No.
  • Clear cache and reindex again:
				
					php bin/magento cache:flush
php bin/magento indexer:reindex
				
			

Advanced Troubleshooting: Diving into Elasticsearch Logs

If the basic steps didn’t solve the issue, it’s time to get technical.

1. Enable Developer Mode:

				
					php bin/magento deploy:mode:set developer

				
			

2. Check Elasticsearch Logs:

  • Elasticsearch logs are typically found in /var/log/elasticsearch/.
  • Look for errors related to indexing or query parsing.

3. Use Magento’s Query Debugging:

Magento logs search queries in debug mode. This helps you see how Magento is sending search requests to Elasticsearch.

  • Enable debug logging in Stores > Configuration > Advanced > Developer > Debug.

4. Direct Query Testing:

Run direct queries against Elasticsearch to see if the SKU exists in the index:

				
					curl -X GET "localhost:9200/magento2_product_1_v2/_search" -H 'Content-Type: application/json' -d'{"query":{"match":{"sku":"123-456"}}}'
				
			

If the SKU shows up here but not in Magento, the issue lies within Magento’s configuration.

When to Consider Extensions or Custom Solutions

magento solution

If you’re still struggling, consider using third-party search extensions like:

  • Mirasvit Advanced Search
  • Amasty Elastic Search
  • Algolia Search for Magento

These tools offer more robust search capabilities, including better handling of SKUs and advanced configurations.

Final Thoughts

Troubleshooting Magento SKU search issues can be frustrating, but with the right approach, most problems are fixable. Start with the basics: check attribute settings, reindex, and verify Elasticsearch configurations. Then move into advanced troubleshooting if needed.

Remember, Magento search is only as good as the data it indexes and the way it’s configured. Keep things tidy, regularly reindex, and you’ll minimize search headaches.

Professional Magento Services That Power Your Store

5MS offers reliable Magento development and support to keep your e-commerce business running smoothly.

Page Load Time of under 0.3 seconds!

12+

Years on average of clients staying with us

15+

Years of experience

Want to experience fastest and most reliable Magento Support?