Sub topic 15
Measuring and Improving Search
This chapter assumes you have read the earlier chapters on search input, results, filters, and empty states. It also assumes you can read basic TypeScript. You will learn which signals show whether a search design works, how to log them, and how to turn them into changes you can test.
Why you need to measure
Search feels fine to the people who build it. They know what to type, they know the catalog, and they test with queries they expect to work. Real users type misspelled words, vague phrases, and product codes you never planned for. Measurement shows you what those users actually do.
A good measurement plan answers three questions:
- Are people finding what they came for?
- How much effort does it take?
- Where does the design fail, and what should we change first?
The concept graph for this tutorial links measurement to two earlier areas: results presentation and empty states. These are the places where search succeeds or fails, so most metrics attach to them.
What to log
Metrics come from events. If you log the wrong events, you cannot compute the right numbers later. Log a small, consistent set from the start.
| Event | When it fires | Key fields |
|---|---|---|
| `search_submitted` | The user submits a query or picks a suggestion | query, source (typed, suggestion, history), session id |
| `results_shown` | Results render | query, result count, latency in ms, active filters |
| `result_clicked` | The user opens a result | query, result id, position, session id |
| `filter_changed` | A filter is added, removed, or reset | filter name, value, action |
| `search_reformulated` | A new query follows within the same session | previous query, new query |
| `search_abandoned` | The session ends with no click | query, result count |
Two points matter here. First, record the position of every click. Without it you cannot tell whether a good result sits at rank 1 or rank 15. Second, record the result count with every search, including zero. A zero-result search is one of the most useful signals you have.
A minimal logger in TypeScript:
type SearchEvent =
| { type: "search_submitted"; query: string; source: "typed" | "suggestion" | "history"; sessionId: string; at: number }
| { type: "results_shown"; query: string; resultCount: number; latencyMs: number; sessionId: string; at: number }
| { type: "result_clicked"; query: string; resultId: string; position: number; sessionId: string; at: number }
| { type: "filter_changed"; name: string; value: string; action: "add" | "remove" | "reset"; sessionId: string; at: number };
const buffer: SearchEvent[] = [];
function track(event: SearchEvent): void {
buffer.push(event);
}
function flush(send: (batch: SearchEvent[]) => void): void {
if (buffer.length === 0) return;
send(buffer.splice(0, buffer.length));
}
track({
type: "results_shown",
query: "boots",
resultCount: 24,
latencyMs: 180,
sessionId: "s1",
at: Date.now(),
});
flush((batch) => console.log(JSON.stringify(batch)));Treat queries as personal data. People type names, email addresses, and health terms into search boxes. Decide how long you keep raw queries, strip obvious identifiers, and follow your privacy rules.
Core metrics
Zero-result rate
This is the share of searches that return nothing.
zero-result rate = searches with 0 results / all searches
A high rate points to gaps in the catalog, missing synonyms, or weak typo tolerance (see the chapter on forgiving queries). Do not stop at the overall rate. List the top zero-result queries by frequency. A few repeated queries often account for most of the problem, and each one is a clear task: add a synonym, add a product, or write a better empty state.
Click-through rate and click position
Click-through rate (CTR) is the share of searches that lead to at least one click on a result.
CTR = searches with at least one click / searches with results
Look at the position of the first click as well. If most clicks land on results 6 to 10, your ranking probably puts the wrong items first. If users scroll past the first screen before clicking, the top results are not convincing.
Reformulation rate
A reformulation is a new query in the same session that follows a query the user just tried. One reformulation is normal. A chain of three or four means the user is struggling. Compare the first and second query to learn why. Adding a word usually means the first results were too broad. Replacing a word often means a vocabulary mismatch.
Abandonment and success
Abandonment means the user leaves without a click, a purchase, or another success action. Be careful with this number. A user who sees the answer in a result snippet may not need to click, so a "good abandonment" exists. You need a clear definition of success for your product: a click, an add to cart, a message sent, a document opened. Define it before you read the numbers.
Filter use
Track which filters people use, in what order, and how often they reset. Three patterns are worth watching:
- A filter nobody uses may be hidden, confusing, or unnecessary.
- A filter used on almost every search suggests the default results are too broad, or that the filter should become a sort order or default.
- A high reset rate right after a filter is applied suggests the filter produced bad results, often an empty state.
Latency
Record the time from submission to rendered results. Report percentiles, not just the average. The average hides slow outliers. A 95th percentile (p95) is the value that 95 percent of searches beat. If p95 is slow, one in twenty users waits too long, even when the average looks fine.
A small function to compute these from logged data:
type SearchRecord = {
query: string;
resultCount: number;
clicked: boolean;
firstClickPosition?: number;
latencyMs: number;
};
function percentile(sorted: number[], p: number): number {
if (sorted.length === 0) return 0;
const index = Math.min(sorted.length - 1, Math.ceil((p / 100) * sorted.length) - 1);
return sorted[Math.max(0, index)];
}
function summarize(records: SearchRecord[]) {
const total = records.length;
const zero = records.filter((r) => r.resultCount === 0).length;
const withResults = records.filter((r) => r.resultCount > 0);
const clicked = withResults.filter((r) => r.clicked).length;
const latencies = records.map((r) => r.latencyMs).sort((a, b) => a - b);
return {
zeroResultRate: total === 0 ? 0 : zero / total,
ctr: withResults.length === 0 ? 0 : clicked / withResults.length,
p50LatencyMs: percentile(latencies, 50),
p95LatencyMs: percentile(latencies, 95),
};
}
console.log(
summarize([
{ query: "boots", resultCount: 24, clicked: true, firstClickPosition: 2, latencyMs: 120 },
{ query: "bootz", resultCount: 0, clicked: false, latencyMs: 90 },
{ query: "rain jacket", resultCount: 8, clicked: false, latencyMs: 400 },
])
);Reading the numbers together
No single metric tells the whole story. Pairs of metrics catch problems that one number misses.
| Pattern | Likely cause | First thing to try |
|---|---|---|
| High zero-result rate, low CTR | Missing synonyms or typo handling | Review top zero-result queries |
| Many results, low CTR, high reformulation | Poor ranking or vague results | Review ranking and result snippets |
| Good CTR, low success after click | Results look right but the destination disappoints | Check titles, images, and snippets for mismatch |
| High filter reset after apply | Filters lead to empty or confusing states | Check facet counts and disabled options |
| Good metrics, slow p95 | Backend or network tail latency | Profile slow queries, add loading feedback |
Quantitative and qualitative methods
Logs tell you what happened. They do not tell you why. Combine them with direct observation.
- Query log review. Read a sample of real queries each week, grouped by frequency. Read the long tail too. You will see intent that your categories do not cover.
- Usability testing. Give five or so participants a task such as "find waterproof boots under 100 dollars" and watch them. Note where they hesitate, retype, or ignore a filter. Small studies find most design problems, though not their exact frequency.
- Relevance judgments. Take 50 to 100 important queries and rate the top results as good, acceptable, or bad. This gives you a baseline you can rerun after a ranking change.
- Feedback prompts. A short "Did you find what you were looking for?" on results or empty pages gives direct signals, but response rates are low and skew toward unhappy users.
Testing changes
Once you have a hypothesis, test it. The usual tool is an A/B test, where one group of users sees the current design and another sees the change.
- State the hypothesis and a primary metric before you start. Example: "Showing facet counts will reduce filter resets."
- Pick guardrail metrics that must not get worse, such as p95 latency and zero-result rate.
- Split users, not searches. If one person sees both versions, their behavior carries over and muddies the result.
- Run the test long enough to cover a full weekly cycle, since behavior differs on weekends.
- Do not stop the moment the numbers look good. Stopping early inflates false positives.
If you lack the traffic for an A/B test, compare before and after with care. Other things change over time, so treat the result as a hint, not proof.
The improvement loop
Measurement works as a cycle, not a one-time audit.
Prioritize by impact and effort. A top zero-result query that appears thousands of times and needs one synonym entry beats a rare problem that needs a rewrite of the ranking.
Common mistakes
- Optimizing one metric. Pushing CTR up by showing misleading titles raises clicks and lowers satisfaction. Always pair a primary metric with guardrails.
- Ignoring zero-click success. Answers shown in snippets or suggestions may satisfy users without a click.
- Averaging latency. Use percentiles.
- Logging without a session id. You cannot compute reformulation or abandonment without linking events.
- Treating all queries equally. A navigational query ("returns policy") and an exploratory query ("gift for dad") have different success signals. Segment them when you can.
- Skipping accessibility checks. Metrics may look fine for the majority while screen reader users fail at a step. Test with assistive technology directly, because aggregate numbers hide small groups.
Summary
Log a small, consistent set of events with session ids, result counts, positions, and latency. Read zero-result rate, CTR, click position, reformulation, filter use, and p95 latency together instead of alone. Add query review and usability tests to learn why. Test changes with a stated hypothesis and guardrails, then repeat the loop.
Exercise
Your search shows a CTR of 62 percent and a zero-result rate of 3 percent, but 35 percent of sessions contain three or more reformulations. What does this suggest, and what two data sources would you check next?
Show answer
Most searches return results and get clicks, so the basics work, but a large group of sessions struggles to reach what they want. This often means a vocabulary mismatch or vague results for some intents. Check the query log for sessions with long reformulation chains, comparing each first and second query to see how users change their words. Also run a relevance judgment on those queries, or run a usability test on the task, to see why the top results do not satisfy them.
Exercise
A teammate wants to ship a new ranking and says CTR rose from 55 to 60 percent in the first two days of an A/B test. Name two reasons not to ship yet.
Show answer
Two days does not cover a full weekly cycle, and stopping early when numbers look good inflates false positives. Also, CTR alone can rise through misleading results, so the test needs guardrail metrics such as reformulation rate, post-click success, and p95 latency before a decision.