Shopify Search Not Finding SKUs? How to Fix Predictive Search Issues

Hey everyone! I’ve been digging through the community forums again, and a really common pain point for store owners came up that I wanted to chat about. It’s all about Shopify’s search functionality, specifically when it seems to go a bit wonky and stops finding products by their SKUs or partial terms.

Recently, a store owner named rachaelannewalker posted about a classic scenario: they had products like "JM-XL1" and "JM-XL2" that used to pop up when searching for just "jm-xl". But suddenly, the search only worked if they typed the exact SKU. And the kicker? They hadn't touched their Dawn theme. Sound familiar?

Why Your Shopify Search Might Be Acting Up

This is a super frustrating issue, especially when you haven't made any obvious changes. Lumine, another helpful community member, really hit the nail on the head by pointing out a crucial distinction: Shopify actually uses different search engines for your admin panel and your storefront. The one customers use on your site (the storefront search) is the one that runs through your theme.

Here’s the thing about storefront search:

  • No Guarantee on Partial Matches for SKUs: Shopify’s default storefront search doesn't always guarantee partial or substring matching on variant SKUs. This means if you type "jm-xl", it might not inherently know to look for "JM-XL1".
  • Hyphenated Terms Get Split: Lumine also highlighted that hyphenated terms (like "jm-xl") can often get split into separate search tokens. So, instead of searching for "jm-xl" as one unit, it might be searching for "jm" AND "xl" independently, which can throw off results.

If your admin search still finds "JM-XL1" when you type "jm-xl", but your storefront doesn't, it's a clear sign the issue is with your storefront's indexing or how your theme handles search, rather than a problem with your product data itself.

Solution 1: The Quick & Easy Fix (Product Tags)

So, what can you do if you're experiencing this? Lumine offered a really solid, non-code workaround:

Add Your SKUs as Product Tags

The most reliable way to make sure a specific value is searchable without diving into code is to put it into a field that search actually indexes well. Product tags are perfect for this!

Here's how you can do it:

  1. Go to your Shopify Admin: Navigate to Products.
  2. Select the Product: Find the product (or products) with the SKU you want to make searchable.
  3. Add a Product Tag: In the product details page, scroll down to the Organization section on the right sidebar. In the Tags field, add the specific SKU part you want customers to find. For example, for "JM-XL1", you might add "JM-XL" as a tag.
  4. Save Your Changes: Don't forget to hit Save!

By doing this, when a customer searches for "jm-xl", Shopify's search will pick up on the product tag, and your products will appear in the results.

Solution 2: Level Up Your Search with Code (For the Tech-Savvy)

For those comfortable with a bit of theme customization, tim_tairli from the community shared a more direct approach by modifying your theme's predictive search JavaScript. This solution directly tells Shopify's predictive search API to include variant SKUs in its search fields.

Understanding Predictive Search Fields

By default, Shopify's predictive search (the one that shows suggestions as you type) typically searches only a few key fields: title, product_type, variants.title, and vendor. The good news is, you can expand this list!

Tim_tairli referenced the Predictive Search API reference, which is a great resource for understanding how these requests work.

Modifying predictive-search.js in Dawn Theme

If you're on the Dawn theme (like rachaelannewalker) or a similar modern Shopify theme, you'll likely find the relevant code in your assets/predictive-search.js file. Always, always make a duplicate of your theme before making any code changes!

Here are the steps:

  1. Duplicate Your Theme: In your Shopify admin, go to Online Store > Themes. Find your live theme, click Actions, and select Duplicate. Work on the duplicate.
  2. Edit Code: On your duplicated theme, click Actions > Edit code.
  3. Locate predictive-search.js: In the left-hand sidebar, open the Assets folder and find predictive-search.js.
  4. Find the Fetch Line: Look for a line similar to this (around line 179 or similar, depending on your Dawn version):
    
          
    1. getSearchResults(searchTerm) {
    2. const queryKey = searchTerm.replace(' ', '-').toLowerCase();
    3. this.setLiveRegionLoadingState();
    4. if (this.cachedResults[queryKey]) {
    5. this.renderSearchResults(this.cachedResults[queryKey]);
    6. return;
    7. }
    8. fetch(`${routes.predictive_search_url}?q=${encodeURIComponent(searchTerm)}§i {
    9. signal: this.abortController.signal,
    10. })
    11. .then((response) => {
    12. if (!response.ok) {
    13. var error = new Error(response.status);
    14. this.close();
    15. throw error;
    16. }
    17. return response.text();
  5. Modify the Fetch Request: You need to add a parameter to this fetch request to include variants.sku in the search fields. Change the line from step 4 to something like this:
    fetch(`${routes.predictive_search_url}`
    +`?q=${encodeURIComponent(searchTerm)}`
    +`§i
    +`&${encodeURIComponent("resources[options][fields]=title,product_type,variants.title,vendor,variants.sku")}`, {
    

    This code snippet essentially tells the predictive search API, "Hey, when you're searching, also look in the variants.sku field, alongside the default ones."

  6. Save and Test: Save the file and then thoroughly test the search functionality on your duplicated theme to ensure everything works as expected. Check for both partial SKU matches and how it affects other search terms.

It’s important to note that predictive search has its own logic, and sometimes even with this modification, partial matches for complex or very short SKUs might still be a bit finicky. But this change significantly expands what the predictive search considers.

Wrapping It Up

Dealing with unexpected changes in core store functionality like search can be a real headache. Whether you go with the simple product tag workaround or dive into theme code, the goal is to make your store as easy to navigate as possible for your customers. Remember, the community is a fantastic resource for these kinds of specific issues, and often, someone else has already figured out a clever solution!

Always test any changes in a development or duplicated theme environment first. Happy searching!

Share:

Use cases

Explore use cases

Agencies, store owners, enterprise — find the migration path that fits.

Explore use cases