Query Rewrite for Ecommerce Search: How ShopGate Turns Messy Queries into Catalog-Safe Intent
Published on January 27, 2025
Read in RomanianEcommerce search doesn't fail because ranking is hard.
It fails because the query is messy -- and the catalog is strict.
Users type slang, typos, abbreviations, mixed languages, and half-sentences. Catalogs contain structured product names, attributes, and categories that rarely match how humans search.
That gap is exactly what query rewrite is for.
In this article we explain what query rewrite really means in ecommerce, why naive "synonyms" aren't enough, and how ShopGate approaches rewrite in a catalog-safe way.
What "Query Rewrite" Means in Ecommerce (Not Web Search)
Query rewrite is the process of transforming a user's raw search input into a cleaner, more catalog-compatible query -- without changing what the user intended.
In ecommerce, rewrite is not about producing a "better sentence".
It's about producing a query that:
- matches how products are named in the catalog
- preserves the user's intent (product type, brand, constraints)
- avoids inventing details that are not present in the catalog
A good rewrite improves recall and protects precision.
Why Synonyms Alone Don't Solve Ecommerce Search
Many stores start with synonym lists:
- "flex" -> "angle grinder"
- "surubelnita" -> "șurubelniță"
- "ulei" -> "oil"
This helps, but breaks quickly because:
- synonyms are ambiguous ("disc" can mean multiple things)
- they don't encode constraints (size, model, compatibility)
- they don't scale across industries and catalogs
- they can create false positives (rewriting into products the store doesn't carry)
Synonyms are a tool -- not a strategy.
The ShopGate Goal: Catalog-Safe Intent Routing
At ShopGate we treat ecommerce search as an intent-to-catalog mapping problem.
We want each query to land in the right "semantic bucket" for that specific store:
- the right product family / category
- with the right brand constraints
- and with the right attributes extracted when possible
The key word is specific store.
A rewrite model that works "generically" on the internet is not enough.
It must be constrained by what the merchant's catalog can actually satisfy.
How ShopGate Handles Query Rewrite (High Level)
ShopGate's rewrite pipeline is designed around safety and merchant specificity:
- Normalize the query
- casing, punctuation, diacritics
- basic cleanup and tokenization
- Detect strong signals
- brand mentions (including common misspellings)
- product-type keywords
- measurable facets (e.g., 125mm, M14, 18V)
- Rewrite conservatively
- fix obvious typos
- map known slang -> catalog terminology (only when supported)
- keep intent, avoid guessing
- Return a catalog-compatible query
- optionally plus structured fields (brand/type/facets) if the integration supports it
The rule: if we're not confident, we don't "hallucinate" a rewrite. We keep the query close to the original and prioritize safe recall.
What ShopGate Does Today
Today, ShopGate can be configured with merchant-specific knowledge such as:
- brand lexicons and common variants
- frequent search terms / keywords
- category vocabulary used by that merchant
- industry-specific slang mappings (auto / agro / power tools)
This allows rewrite to stay aligned with the store's real product language and reduce:
- zero-result searches
- irrelevant result sets
- user frustration
What We're Adding Next (Catalog Ingestion and Per-Merchant Prompt Synthesis)
The next step (and the core scaling unlock) is automated catalog ingestion.
In practice, for each merchant we can ingest product data via:
- product feeds (CSV/XML/Google Merchant)
- APIs (where available)
- sitemaps / structured pages
- crawl-based extraction where allowed
From this catalog snapshot we can derive:
- the most frequent product tokens
- a validated brand list (what actually exists in the store)
- category "buckets" and their vocabulary
- attribute patterns (sizes, voltages, dimensions, standards)
Then we build a merchant-specific prompt (and rules) that constrain the rewrite engine:
- "Only rewrite into terms that appear in this catalog"
- "Prefer these category vocabularies"
- "Use these brand spellings / variants"
- "Do not invent compatibility claims"
This is how we keep rewrite safe and relevant -- even for messy, domain-specific search traffic.
Why Merchant-Specific Prompts Beat Generic Rewrite
Generic rewrite engines are tempted to "improve" text.
In ecommerce, improvement must be constrained by inventory.
Merchant-specific prompts give us:
- fewer false positives
- better mapping to real categories
- safer brand handling
- higher trust in the results
And most importantly:
- a repeatable approach that adapts to each store's catalog
Examples (Before -> After)
Use examples that are realistic but safe:
- "flex mare bosch" -> "polizor unghiular bosch"
- "disc frana fata golf 5" -> "disc frână față golf 5"
- "bujii iridium toy" -> "bujii iridium toyota"
- "polizor 125" -> "polizor unghiular 125 mm"
Note: only use "Toyota" rewrite if Toyota is allowed by the merchant vocabulary/catalog constraints.
Safety Rules (Non-Negotiable)
ShopGate rewrite follows strict rules:
- never invent brands, parts, models, or specs
- never "force" a category if signals are weak
- prefer conservative edits over aggressive rewrites
- constrain output to merchant vocabulary where possible
- if uncertain, keep the query close to the original
This is how we improve search without breaking trust.
Final Thoughts
Query rewrite is not a nice-to-have.
For real ecommerce search -- especially in complex verticals -- it is the bridge between messy human language and strict catalogs.
ShopGate's approach is simple:
- be merchant-specific
- be catalog-safe
- be conservative when uncertain
By Alexandru Gherghe, founder at ShopGate.ai
Want to see how your store's queries would be rewritten safely? Try the ShopGate demo with real searches.