We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

GraphQL query to use wildcard in SKU

GraphQL query to use wildcard in SKU

Korsmet
Shopify Partner
1 0 0

 

Our staff and clients are used to search by the last 4 or 5 digits in the SKU. I want to enhance this in our search system. However even when I do use the query like query:( sku: *12345*), it still won't match those end with 12345. However, it does able to grab those start with 12345.
The same syntax work just fine on other fields such as title or category.

 

Reply 1 (1)

Dotsquares
Shopify Partner
460 29 61

Hi @Korsmet 

Thank you for reaching out.

I understand you’re trying to enhance the search functionality to support partial SKU matches, especially by the last 4–5 digits — which makes perfect sense given your team’s workflow.

You're correct that wildcard searches like sku:*12345* can behave inconsistently across fields depending on how those fields are indexed and analyzed. In many systems, including some search engines, SKU fields are often treated as non-analyzed or keyword-type fields, meaning wildcard searches only match from the start of the string — which is why you're seeing matches only for SKUs that start with those digits.

To support suffix or mid-string matching on the SKU field, here are a few options you might consider:

Change the field mapping (if possible) – Ensure the sku field is analyzed (e.g., with an n-gram or edge n-gram tokenizer) so it supports more flexible partial matching.

Duplicate the field with custom analysis – If your platform allows it, create a secondary sku_search field that is analyzed differently and use that for partial match queries.

Use a script or custom query logic – In some systems, you can implement a script-based search to match end patterns, although this may have performance implications.

 

Dotsquares Ltd


Problem Solved? ✔ Accept and Like solution to help future merchants.


Shopify Partner Directory | Trustpilot | Portfolio