Skip to content

SearchingBySkuBasics

Richard BAYET edited this page Mar 22, 2019 · 1 revision

Searching By SKU (Basics)

Product references can take many shape and form and not necessarily conform to EAN13 or UPC-A formats, but most certainly usually look nothing at all like human language.

In that regard, searching by SKU is a very specific kind of search, that can be described as only tangentially related to fulltext search, and even have completely opposite goals in terms of accuracy.

Table of contents

Scope

Searching by SKU is not really a core feature of Elasticsuite, but we have been refining it over the releases to try to provide at least exact matching and some degrees of partial matching against the Luma demo catalog SKU morphology.

That morphology is one or several group of letters or digits either glued together or separated by a dash - or any non-alphanumerical character. (Note that this definition covers both EAN13 and UPC-A formats.)

Luma catalog examples :

  • 24-MB01, 24-MB02, ..., 24-MB06
    • 3 groups of symbols (2 digits, 2 letters, 2 digits)
    • the last 2 groups glued together
    • the first group being separated from the others by a dash
  • MH01, MH01-XS-Black, MH01-XS-Gray, MH01-XS-Orange, etc
    • 2 or 4 groups of symbols
    • the simpler format for the parent/configurable product (MH01)
    • the longer format for the product variations (MH01-[Size]-[Color])

Exact matching

If you have a product visible in search, searching exactly for its SKU should either redirect you to the product page (if one result redirect is enabled) or lead you to a search results page with only that product.

Given a product already visible in search with a SKU of SOME-9013THING, searching for "SOME-9013THING" would only lead you to a search results page with several products if that SKU is mentioned in other products' indexed attributes, say, for instance, if that SKU is referenced in another product's description as a compatible or alternative product.

You will also have this issue if the SKU belongs to a product that is available both as a simple product and as part of a grouped or bundle product.

Separator characters are a non-issue : you can also find the corresponding product if you omit existing separators or add non-existent ones, for instance searching for "SOME9013THING" or "SOME-9013-THING" or even "SOME 9013 THING" instead of the actual SOME-9013THING SKU.

Real examples on our Luma demo site

  • Searching for the 24-MB03 product SKU will redirect you to the product page (because one result redirect is enabled on our demo site)
  • Searching for 24-WG084 will correctly display a search results page with two products : the expected simple product and the bundle product which the simple product is a part of
  • Searching for 24-WG087 will correctly display a search results page with the bundle and the grouped products that the corresponding, not visible individually, simple product is a part of

Partial matching

To put it shortly : partial matching works... partially.

What works

If you perform a search by a homogeneous (ie made only out of either letters or digits) and complete part of a SKU, that part being either a prefix, a suffix or a middle part of that SKU, the corresponding products will be found.

For instance, given the SOME-9013THING SKU example, searching for the "SOME" SKU prefix will find as expected all the available products with a SKU pattern of SOME-yyyyZZZZ.

Searching for "9013" and "THING" will find all products having respectively, XXXX-9013ZZZZ and XXXX-yyyyTHING as SKU patterns.

It will also work if your search is made of two complete and homogeneous parts, for instance "SOME-9013" or "9013THING". Please note that the separator characters are also a non-issue in that case : searching for "SOME9013" or "SOME-9013" will both match any SOME-9013ZZZZ SKU.

Of course, according to your catalog and more so than in exact matching, when searching by a SKU part you might not only find the products you are looking for but also all the other products with that (SOME, 9013 or THING) part being present in other indexed attributes (title, description, etc) either as a reference or as an actual word.

Real examples on our Luma demo site

  • Searching for 24-MB will list all bag products with a SKU of 24-MB[number], same thing for 24MB
  • Searching only for MB will also list the same bag products because there are no other products with MB in their SKU or the other indexed attributes
  • Searching only for 24 will find those 24-MB[number] bag products, but of course, other products with a 24 SKU prefix
  • Searching for MB-03 will redirect you to the only bag product with a partial match on the SKU (because one result redirect is enabled on our demo site).

What does not work

At this moment, implicit wildcard matching does not work when searching by an interrupted/incomplete SKU part.

For instance, given a existing SKU of SOME-9013THING :

  • searching for SOM (incomplete first alphabetic part)
  • searching for SOME-9 or 901 (incomplete numeric part)

Important : If your store uses exclusively EAN13 or UPC-A, it means that partial matching will never work, as your SKUs are formed of a single numeric part of 13 or 12 digits.

Real examples on our Luma demo site

  • Searching for 24-MB0 will not return any of the 24-MB0X bag products
  • Searching for 24-M will not return any of them either

Going further

If you are already familiar with ElasticSearch concepts of analyzers, tokenizers and token filters, you can head to detailled explanations page for the reasons behind the current behavior and how you try to customize your Elasticsuite installation to better fit your needs.

Clone this wiki locally