
Evaluating Search Quality Before and After Every Change
Relevance changes are code changes. Build a golden query set from real traffic, score before and after with precision-at-k and NDCG, and gate CI on regressions.
TL;DR: Search quality evaluation is how a site team finds out whether a relevance change helped before users do. This article treats relevance configuration as code with a regression suite: a golden query set sourced from real traffic, graded judgments stored beside the config, precision-at-k and NDCG read as before/after deltas, a CI gate on a pinned fixture index, and an honest account of what online testing can and cannot prove on a site with modest traffic.
Relevance changes regress silently
Consider an illustrative case from tuning a site search. A support ticket arrives: searching "wireless headphones" returns cables first. Someone raises the weight on the product title field, adds a synonym, re-runs the complaint query, and it looks right. The change ships. Later, a different ticket reveals that brand-name queries now rank accessories above the flagship products, because the same weight change that fixed one query quietly reshuffled dozens nobody re-checked.
Nothing crashed and nothing was logged. That is what makes relevance regressions expensive: they are silent, and without a test suite every tuning session is net-unknown.
The reframe that organizes this article is simple. Relevance configuration is code. It is versioned, reviewed, and change-logged, the same discipline the relevance-tuning article on this topic argues for. Code that can regress gets a regression suite. For search, that suite is the golden query set: a curated list of real queries, each paired with judged right answers, run before and after every change.
The gate applies to more than field weights. Everything that can move a ranking counts as a relevance change:
- Field weights, boosts, and ranking rules
- Synonym and dictionary entries, including stop words and stemming exceptions
- Analyzer changes; changing an existing field's analyzer is also a reindex event and follows the sync article's reindex discipline, while a search-time analyzer change may not need one (in Elasticsearch, for example, the analyzer setting cannot be updated on existing fields using the update mapping API, but the search_analyzer setting can, provided the field's existing analyzer and type are repeated in the updated definition; as of Nov 2026, Elastic documentation)
- Recovery-ladder rungs such as typo tolerance, relaxed matching, and zero-result fallbacks
- Hybrid retrieval settings: the keyword/vector blend, candidate pool sizes, and re-ranking thresholds
The evidence hierarchy, stated up front: offline comparison on the golden set comes first, because it runs before anything ships and is repeatable. Online movement in the analytics article's metrics comes second, because it reflects real behavior but arrives late and noisy. Neither substitutes for the other.
Building the golden query set
A golden set built from a brainstorm tests the queries the team imagines. A golden set built from traffic tests the queries users actually type. Four sourcing streams cover the ground:
| Stream | What it contributes | Why it belongs |
|---|---|---|
| Head queries | The highest-volume queries from search logs | These must never break; they carry the highest volume, so a regression here reaches more searches than anywhere else in the set |
| Sampled torso queries | A random sample from the mid-frequency band | Coverage of the long middle that tuning often degrades without anyone noticing |
| Past failures | Every production complaint, converted into a test case | Once fixed, a failure becomes a permanent assertion so it cannot silently return |
| Zero-result mining | Queries from the recovery ladder's zero-result logs | Tests the recall side: queries that should find something and currently do not |
Research on e-commerce search behavior is a useful check on coverage. Baymard Institute's search usability research classifies queries into distinct types, such as exact product searches, feature and attribute searches, symptom and problem searches, and non-product queries like shipping or returns (as of Nov 2026, Baymard Institute). If a golden set contains only exact-product queries, it cannot catch a regression on the other types. Map the set against a taxonomy like this and fill the gaps.
Judgments are graded, not binary. For each query, people who know the domain record which documents are right answers and how right, on a simple scale:
- 3: the ideal answer
- 2: a good answer
- 1: relevant but weak
- 0: not relevant
Each judgment carries a one-line rationale, the only record of why a grade was given when someone disputes it much later. Store the judgments as fixtures in the repository, next to the relevance configuration they test, so a pull request that changes a synonym list can update the judgments it affects and a reviewer sees both in one diff. An illustrative fixture file (the SKUs and grades are examples):
# search/golden/laptop-charger.yaml
query: "laptop charger"
stream: head
judgments:
- doc: sku-4412 # 65W USB-C charger
grade: 3
why: "Direct match for a laptop charger query"
- doc: sku-4418 # 100W GaN charger
grade: 2
why: "Correct category, higher wattage than this query needs"
- doc: sku-2210 # USB-C cable, 2m
grade: 1
why: "Accessory users often want alongside, not the answer"
- doc: sku-9001 # Laptop sleeve
grade: 0
why: "Same department, wrong intent"Set hygiene keeps the suite honest. Queries retire when the products or content they target retire. New query patterns join as traffic shifts, whether that is a seasonal range, a new product line, or a new way people describe an old product. And the whole set is re-reviewed on a stated cadence, the same way dependency updates are. A stale golden set is worse than none, because it green-lights changes against yesterday's site: every check passes and none of them test the catalog users actually search.
Size honesty. As a rule of thumb rather than a measured threshold, tens to low hundreds of judged queries can serve as a starting suite for a site team. Shared research benchmarks serve a different goal, publishing results that are comparable across systems; a site team's goal is narrower, catching regressions before users do.
Offline metrics without metric worship
This article works with two metrics.
Precision-at-k asks: of the top k results, how many are judged relevant? With k set to what a results page shows above the fold, for example 5 or 10, it matches how users experience search. If four of the top five results for "laptop charger" are graded 1 or higher, precision-at-5 is 0.8. It is easy to explain to anyone and easy to reason about when it moves.
NDCG (normalized discounted cumulative gain) adds two things precision-at-k ignores: grades and position. A grade-3 result at position one is worth more than a grade-3 result at position five, and both are worth more than a grade-1 result anywhere. NDCG sums the graded gains down the ranking, weighting each gain less the lower its position, then normalizes against the ideal ordering so every query scores between 0 and 1. The definition comes from the standard information-retrieval literature (Järvelin and Kekäläinen, Cumulated gain-based evaluation of IR techniques, ACM Transactions on Information Systems, 2002), and it is used here for one reason: it rewards putting the best answers highest, which is what a tuning change is trying to do.
Some dedicated engines can compute these metrics natively. Elasticsearch, for example, exposes a ranking evaluation API that scores rated search queries with precision, recall, mean reciprocal rank, discounted cumulative gain (optionally normalized), and expected reciprocal rank (as of Nov 2026, Elastic documentation). Where the engine does not, a short script that runs the queries and scores the results against the fixtures does the same job.
The point is comparison, not absolutes. An NDCG of 0.7 means nothing on its own. It depends on the grading scale, the set composition, and how strict the judges were. The same set scored before and after a change means everything, because every other variable is held constant.
And per-query deltas matter more than the aggregate. An average that held steady can hide five queries that broke badly, offset by ten that improved slightly. The report a reviewer needs is not "NDCG 0.71 to 0.72" but the list of queries that moved, sorted by how far they fell.
The CI wiring follows directly, sketched here as pseudo-configuration rather than any CI system's syntax:
# .ci/search-relevance.yml
on:
changes:
- search/config/** # weights, rules, synonyms, analyzers
- search/golden/** # judgments themselves
steps:
- load fixture index from snapshot: search/fixtures/corpus-2026-09.ndjson
- apply candidate config
- run golden set, score precision@5 and NDCG@10 per query
- compare against baseline scores from main
fail_if:
- aggregate NDCG@10 drops by more than 0.01
- any head query drops by more than 0.10
- any past-failure query drops below its recorded floor
report:
- per-query deltas, largest regressions firstThree details make this work. The fixture index is a pinned corpus snapshot, so data drift from new products or edited content does not masquerade as a relevance change; the snapshot is refreshed deliberately, with its own before/after run. The thresholds cover both the aggregate and per-query regressions, with the tightest rules on head queries and past failures. And the job triggers on any relevance-config change, including judgment edits, so the suite and the config never drift apart. It is the same discipline the sync article borrows for its reindex acceptance gate.
Thresholds are judgment calls, not constants: a threshold that fails every build gets disabled, and one that never fails is decoration.
Online verification and its honest limits
Offline evaluation proves a change behaves as intended on known queries. Online evidence shows what happened when real users met it.
A low-cost observational default is reading the analytics article's metrics before and after a shipped change: zero-result rate, click-through by result position, and reformulation rate. A drop in zero results after a synonym release corroborates the offline result; a spike in reformulations for a query family is a lead for a new golden-set case.
Controlled online experiments go further. An A/B test splits traffic between the old and new ranking and compares outcomes. Interleaving is a design built for ranking comparisons: instead of splitting users, it mixes results from both rankings into one list for each search and scores which ranking's results attract the clicks. A large-scale study used data from two major commercial search engines and arXiv.org. On the arXiv.org data, interleaving reached a high level of confidence much faster than conventional methods based on absolute metrics in most cases; on the Yahoo! data it typically produced a statistically reliable preference after much less data than any absolute metric, and against Clicks@1 it needed more than an order of magnitude fewer queries for all but one pair of ranking functions (Chapelle et al., Large-Scale Validation and Analysis of Interleaved Search Evaluation, ACM Transactions on Information Systems, 2012). The methodology depth, including power analysis, significance, and bias corrections, belongs to the experimentation literature; the concept is what a site engineer needs to recognize when it applies.
Here is a limit worth stating plainly. Many sites do not have the search volume for statistically meaningful online tests on any reasonable timescale. When searches spread across thousands of distinct queries, even a long-running test may separate signal from noise only on the head. For those sites, the offline golden-set discipline is not the warm-up before "real" testing. It is the main event. Observational metrics are then read as trends that confirm or question the offline result, never as verdicts on their own.
Crowd-judgment platforms and LLM-as-judge pipelines can scale grading, but both trade domain knowledge for volume, and a model's grades need their own validation against human judgments before they can gate anything. They can supplement a golden set; they should not replace the people who know the catalog.
The boundaries of this article are deliberate. How search metrics are instrumented and logged is the analytics article's job; here they are consumed as evidence. Which levers to move when a regression appears is the relevance-tuning article's job; this article owns detection and proof. And business-outcome attribution, such as revenue per search or conversion credit, belongs to the journey-measurement literature outside this topic.
What this article adds is the standing rule this whole topic points to: no relevance change without before/after evidence. Each relevance change ships with a golden-set comparison attached to its pull request, the way code ships with its tests.