Fuzzy search for part numbers and serial codes should recover ordinary typing and formatting mistakes without silently selecting the wrong item. This workflow explains how to normalise identifiers, choose an appropriate matching strategy, set confidence bands, test ambiguous cases, and monitor results as code formats and catalogues change.
Overview
Part numbers, SKUs, model references, and serial codes look like ordinary text, but they should not be searched like ordinary product descriptions. A small difference can represent a harmless typo, a meaningful variant, or a completely different physical item. For example, AB-1207, AB1207, and AB 1207 may be equivalent representations, while AB-1207 and AB-1270 may refer to different components.
A safe product code matching algorithm therefore separates format tolerance from identity tolerance. It can usually ignore approved differences such as spaces, hyphens, and letter case. It should be much more cautious about substitutions, missing characters, transposed characters, and partial input.
The most reliable workflow has five stages:
- Classify the identifier field and its risk.
- Store a canonical representation alongside the display value.
- Generate a small candidate set using exact and approximate retrieval.
- Rank candidates with rules suited to the identifier format.
- Send uncertain results to a confirmation step rather than forcing a match.
This approach is useful in ecommerce search, warehouse tools, service desks, procurement systems, ERP migrations, and catalogue imports. It also creates a repeatable basis for auditing search quality. For broader catalogue problems involving variants and duplicate listings, see the product catalogue fuzzy-matching workflow.
What to track
1. Identifier type and risk
Begin by documenting what each field represents. A stock-keeping unit may be shared across inventory records, while a serial number is often intended to identify one physical unit. A model number may be searched before purchase; a serial code may be used during repair or warranty work. These contexts require different tolerance.
| Identifier | Useful tolerance | Recommended result behaviour |
|---|---|---|
| SKU or catalogue code | Case, spaces, approved punctuation, limited typo tolerance | Show ranked alternatives when confidence is not decisive |
| Part number | Known separators and carefully tested character errors | Prefer exact or high-confidence matches; display variant details |
| Model number | Formatting differences and partial prefixes | Allow browsing, but distinguish families and revisions |
| Serial number | Usually formatting only; very limited character tolerance | Ask for confirmation before linking to a specific asset |
Track the field's allowed alphabet, minimum and maximum length, fixed positions, revision markers, and whether leading zeroes matter. If a code contains check digits or a manufacturer prefix, preserve those rules. A generic fuzzy matching algorithm should not override domain constraints.
2. Normalised and original values
Keep at least two values: the original identifier for display and audit purposes, and a canonical value for lookup. A basic query-normalization checklist may include:
- Trim leading and trailing whitespace.
- Convert letters to a consistent case.
- Replace approved separator variants consistently.
- Remove spaces or punctuation only when the field specification allows it.
- Handle visually similar characters explicitly, such as a possible zero and letter O, rather than applying a global substitution.
- Preserve leading zeroes and meaningful revision suffixes.
- Record which transformations were applied.
Do not use broad transliteration or linguistic stemming for technical identifiers unless the data specification calls for it. Identifier matching is generally a character and structure problem, not a semantic search problem.
3. Candidate and outcome data
For each search, record the normalised query, identifier type, number of candidates, selected result, score, matching method, response time, and whether a user confirmed or rejected the result. Also track zero-result searches, queries with many near matches, and cases where an exact match was available but ranked below a fuzzy result.
These logs are more useful than a single overall match rate because they show where the workflow is unsafe or inconvenient. The guide to diagnosing fuzzy search failures from search logs provides a complementary way to structure this review.
Cadence and checkpoints
Use a small test set before release and keep it as a living regression suite. It should contain valid examples, formatting variations, realistic mistakes, and deliberately dangerous near matches.
Build a representative test set
For a code such as ZX-4801-A, include cases such as:
ZX4801A— removed separators.zx-4801-a— different case.ZX-480I-A— a possible one/I confusion.ZX-4810-A— transposed or changed digits.ZX-4801— incomplete suffix.ZX-4801-B— a plausible but different revision.ZX-4801-A-UK— an extended regional or packaging code.
Label each case as an exact match, safe normalisation, acceptable suggestion, ambiguous suggestion, or no match. Include collisions: two catalogue records that become identical after punctuation removal, and two codes that differ by one character but represent different products.
Check in stages
At implementation time, verify the normalisation function independently from the ranking function. Then test candidate retrieval, ranking, user presentation, and logging separately. A change to an index, database extension, or search API can alter candidate order without changing the similarity calculation.
On a monthly or quarterly cadence, review:
- New zero-result and low-confidence queries.
- False matches reported by users or support staff.
- New prefixes, suffixes, revisions, and separator conventions.
- Changes in the distribution of code lengths.
- Latency at common and peak query volumes.
- Searches returning multiple records with nearly identical scores.
Run the regression set after catalogue imports, ERP migrations, schema changes, index rebuilds, or changes to autocomplete. A staged release with a rollback plan is appropriate when changing live matching behaviour; see this staged migration guide.
How to interpret changes
Similarity scores are useful for ranking, but a score is not a universal probability of correctness. A Levenshtein-based score may work well for short, fixed-format codes, while token methods can be misleading when token order or boundaries carry meaning. Character n-gram retrieval can be useful for finding candidates, but it should be constrained by length, prefix, and format rules.
Consider a three-band decision policy:
| Band | Typical action | Guardrail |
|---|---|---|
| High confidence | Return one result or use it for a non-destructive lookup | Require compatible identifier structure and no close competing candidate |
| Review or suggestion | Show a short ranked list with the original code and product details | Do not silently select a record |
| Low confidence | Ask for more input or report no reliable match | Never attach a serial number to an asset automatically |
Set thresholds from labelled examples rather than choosing a convenient number. The threshold may differ by field, code length, and operation. A one-character change in a long catalogue code may be tolerable for a suggestion; the same change in a short serial code may create too many collisions.
Exact matching should normally win when an exact canonical value exists. Fuzzy results should not obscure an exact result merely because another candidate has a slightly higher general similarity score. Add deterministic rules for manufacturer prefix, product family, revision, region, and active catalogue status where those attributes are available.
When results change after a data import, first ask whether the data changed or the algorithm changed. A rise in ambiguous matches may indicate newly added variants rather than a defective matcher. Conversely, a rise in fast, confident but incorrect matches can indicate over-aggressive normalisation or an overly broad threshold.
For algorithm selection and trade-offs between Levenshtein distance, Jaro-Winkler, and Jaccard similarity, consult the comparison guide. For a PostgreSQL implementation, pg_trgm indexing and ranking can help with candidate retrieval, provided the database query is combined with identifier-specific constraints.
When to revisit
Revisit the workflow at least monthly or quarterly, depending on query volume and the consequences of a wrong match. A high-volume ecommerce SKU search may need more frequent review than an internal catalogue used occasionally. The important point is to schedule the review rather than waiting for a visible incident.
Trigger an additional review when a supplier introduces a code family, when product revisions are added, when serial formats change, or when a catalogue is merged. Also review after changes to character encoding, import mappings, database indexes, search-engine settings, autocomplete, or user-interface labels. A change that appears unrelated to fuzzy search can alter the values reaching the matcher.
At each checkpoint, take these practical actions:
- Export a sample of zero-result, low-confidence, and manually corrected searches.
- Classify each case as a normalisation gap, missing data, candidate-retrieval issue, ranking issue, or genuinely ambiguous code.
- Add representative failures and dangerous near matches to the regression set.
- Review thresholds by identifier type instead of applying one global threshold.
- Compare exact-result precedence, false-match reports, ambiguity rate, and response time with the previous checkpoint.
- Document any changed rule, affected code family, and rollback method.
Keep the user interface honest: label suggestions as suggestions, show the entered code, and expose enough product or asset detail for confirmation. If the task involves a consequential update, such as assigning stock or linking a serialised asset, require an explicit confirmation step. This balance delivers typo-tolerant search without treating approximate string matching as proof of identity.