Skip to content

Magento 2: How to Achieve Partial Match Search for SKU and Other Attributes?

I’m encountering a challenge with the search functionality in Magento 2 and could use your expertise. Specifically, the issue revolves around partial match searches, especially concerning the SKU attribute. 🔎🛒

Issue Description:

  • When I search with the exact SKU (e.g., "ML1797"), the product is
    retrieved as expected in the search results. ✅
  • However, when I perform a search with a partial SKU (e.g., "1797"),
    no results are found, which is not the desired outcome. ❌

Objective:

  • I want to configure or customize the search functionality so that partial SKU searches return relevant results.

What I’ve Tried:

Additional Context:

  • Magento Version: 2.4.5-p1
  • Search Engine: Elasticsearch 7
  • Additional Search Module : MGS/InstantSearch
  • No relevant errors in log files.

Questions:

  • 🤔 Is there a configuration or best practice approach to achieve partial match searches for SKU (and potentially other attributes) in Magento 2?
  • 🛠️ If customization is required, could you provide a guideline on how to approach this, especially considering the Elasticsearch engine?

Any insights, advice, or shared experiences would be incredibly helpful! 🙏🚀

Thank you in advance for your time and expertise! 🌟🛍️