Skip to content
← All posts
5 min read Dawid Skłodowski

Search-relevance tuning for e-commerce

Getting search results back is easy; getting the right products in the right order is the real work. A deep-dive on relevance tuning for a store — boosting by business signals, synonyms, typo handling, zero-results, and measuring whether your changes actually help.

Once you have search working — Postgres FTS or Elasticsearch, indexed and querying — you discover that returning matches was the easy 20%. The hard 80% is relevance: making the right products appear in the right order for what each customer actually meant. On a store this is not a nicety; search is one of the highest-converting paths to a sale, and a customer who does not see what they wanted in the first few results buys nothing. Relevance tuning is where search quality — and revenue — is won. Here is what it actually involves.

Relevance is not just text matching

The instinct is to rank by how well the query text matches the product text, and that is the starting point, not the answer. Pure text relevance will happily rank an obscure, out-of-stock product above a bestseller because the obscure one happened to repeat the query word more often. For a store, the best result is not the closest text match — it is the product the customer is most likely to buy. That means relevance must blend text matching with business signals:

  • Popularity / sales. A product that sells well for this query should rank above one that matches the text equally but never sells.
  • Availability. An out-of-stock product is a dead end; it should rank below in-stock ones (or be filtered, depending on your policy) — showing customers things they cannot buy is pure friction.
  • Margin or strategic priority. Sometimes the business genuinely wants to favour higher-margin or promoted lines — a legitimate input, used with care.
  • Recency / freshness. New arrivals may deserve a boost in fashion or seasonal catalogs.

In Elasticsearch this is function scoring: the text-match score is multiplied or augmented by functions of these signals.

# blend text relevance with business signals
Product.search(query: {
  function_score: {
    query: { multi_match: { query: q, fields: ["name^3", "description"] } },
    functions: [
      { filter: { term: { in_stock: true } }, weight: 2 },        # prefer buyable
      { field_value_factor: { field: "sales_count", modifier: "log1p" } } # popular ranks up
    ],
    boost_mode: "multiply"
  }
})

The art is in the weights — how much each signal counts relative to text match. Too much business weighting and search ignores what the customer typed; too little and a bestseller hides on page three. There is no formula; it is iterative tuning against real queries.

Synonyms and query understanding

Customers and your catalog often use different words for the same thing — “trainers” vs “sneakers”, “telly” vs “television”, a brand name spelled three ways. If your product text says one and the customer types the other, a pure match returns nothing, and the customer concludes you do not stock it. Synonyms close this gap: a curated dictionary that treats equivalent terms as the same at search time.

# synonyms.txt
trainers, sneakers, plimsolls
tv, telly, television

Synonyms are one of the highest-ROI relevance investments because they directly recover searches that would otherwise return nothing. They also need curation from people who know the domain and the customers’ vocabulary — this is where search tuning becomes a collaboration with the merchandising team, not just an engineering task. Beyond synonyms, query understanding — recognising that “red running shoes size 10” contains a colour, a category, and a size — lets you route parts of the query to the right fields and facets, a deeper investment that pays off on catalogs with rich attributes.

Typo tolerance, tuned

We covered fuzzy matching earlier; for commerce the nuance is how much fuzziness. Customers fat-finger constantly, so some tolerance is essential — “addidas” must find “Adidas”. But too much fuzziness is its own failure: match too loosely and “boot” returns “boat”, “shirt” returns “short”, and relevance collapses into noise. Tune the edit distance by term length (short words tolerate fewer edits), and prefer exact and prefix matches over fuzzy ones in the ranking, so a genuine match always beats a fuzzy guess. Typo tolerance is a dial, not a switch.

Handle zero results as a designed experience

Every store has queries that legitimately return nothing, and the zero-results page is a conversion event you control. A blank “no results” is a dead end; a good zero-results experience keeps the customer in the funnel:

  • Relax the query automatically — drop the most restrictive term, widen the fuzziness, and show “showing results for the closest match” rather than nothing.
  • Suggest alternatives — popular products, related categories, “did you mean”.
  • Log every zero-results query. This is gold: it is a direct list of demand you are failing to meet — products customers want and either you do not stock or your synonyms/relevance are missing. Reviewing zero-results queries is one of the most productive relevance activities there is.

Measure, or you are guessing

This is the discipline that separates relevance tuning from relevance fiddling: you cannot improve what you do not measure, and relevance feels subjective until you instrument it. The signals that tell you whether a change helped:

  • Click-through rate on results, and rank of clicks — are people clicking the top results, or scrolling past them?
  • Search conversion rate — do searches lead to add-to-cart and purchase?
  • Zero-results rate — what fraction of searches find nothing?
  • Search refinement / abandonment — do customers immediately re-search (a sign the first results missed)?

With these instrumented, relevance tuning becomes an empirical loop: change a weight or add synonyms, watch the metrics, keep what helps. Ideally you A/B test ranking changes, because relevance intuition is often wrong and the data is the arbiter. Without measurement you are endlessly tweaking weights based on whichever query a stakeholder happened to try this morning.

Verdict

Search relevance is where a store’s search stops being a feature that works and becomes a feature that sells. The right result is the product the customer will buy, not the closest text match — so blend text scoring with business signals (popularity, availability, margin) via function scoring, tuned with care so neither dominates. Invest in synonyms and query understanding to recover searches that would otherwise fail, tune typo tolerance as a dial, and design the zero-results page as a kept-in-funnel experience while mining its logs for unmet demand. Above all, instrument it — click-through, search conversion, zero-results, refinement — so tuning is empirical, not superstition. Relevance is never “done”; it is an ongoing, data-driven collaboration between engineering and merchandising, and on a store it is some of the highest-leverage work you can do.