Search Autocomplete: Engineering the Suggest Surface

Search Autocomplete: Engineering the Suggest Surface

Suggest is not a smaller search — it answers every keystroke. Here is the index shape, the keystroke-path bugs, and the quality loop that keeps it honest.

The suggest dropdown is its own subsystem, not a smaller version of the results page — it answers every keystroke instead of a submitted query, can run on a different index shape built for prefix matching, and may have room for less of the ranking logic the results page uses. Treating it as the results query with a limit is one way teams end up with keystrokes that feel slow.

A different subsystem, not a smaller search

The contract is fundamentally different from the results page. A results page answers one submitted query. A suggest dropdown answers every single keystroke, which means its latency budget is far tighter — anchored to research on what feels instantaneous to a human being: Jakob Nielsen's 1993 guidance, drawing on earlier work by Miller (1968) and Card et al. (1991), that 0.1 second is about the limit for having the user feel that the system is reacting instantaneously (Nielsen, Usability Engineering, 1993, via NN/g).

The index underneath suggest can be different in shape, not just smaller in scope. Suggest can run on prefix-oriented structures — edge n-grams and completion indexes, at the level of concept rather than any single implementation — built for starts-with matching, rather than on the full relevance pipeline the results page relies on. Some dedicated search engines, Elasticsearch and OpenSearch among them, ship purpose-built suggest capabilities for exactly this reason, as of November 2026 (engines continue to evolve these offerings). Elasticsearch's documentation adds that its completion suggester uses data structures that enable fast lookups, but are costly to build and are stored in-memory, and OpenSearch's autocomplete guide says its completion suggester's data structure lives in memory. Prefix-oriented structures are one design choice: as of November 2026, OpenSearch's autocomplete guide also lists query-time prefix matching on the last term of a query string, which doesn't require any special mappings but which the guide calls a fairly resource-intensive operation, and Meilisearch's regular search performs prefix search on the last word of a query by default, which its documentation says has a significant impact on search time.

The scope difference follows from the other two: with a tighter latency budget, suggest may have room for less of the ranking logic a results query uses. Treating suggest as "the results query, but with a limit clause" is one way teams end up shipping a suggest dropdown that is noticeably slow to respond to each keystroke.

The investment is worth making because, whenever a user picks a direct entity suggestion, the suggest dropdown is the entire search experience they have — they go straight to the product or article and never see the results page render at all.

It is worth being explicit about what that means for how a team prioritizes engineering effort. A results page that renders a beautifully sorted, well-faceted list is only as good as the query that reaches it, and in sessions where the user picks a suggestion, the query that reaches it was chosen from a dropdown before the user ever saw the results page's own design. Treating suggest as a lightweight afterthought to the results-page project, rather than as a subsystem that earns its own design review and its own performance budget, is how a team ends up polishing the results page while the dropdown that feeds it gets no design review of its own.

What to suggest and where it comes from

Three suggestion types earn a row in a well-built suggest dropdown, and each earns its place for a different reason. Query completions finish what the user is already typing. Direct entities let the user jump straight to a specific product or article without finishing a query at all. Scoped suggestions narrow a term to a category. Mixing all three in one dropdown is fine as long as each type is visually distinct enough that a user understands what selecting it will do.

Completion sources split into a curated seed set and query-log-derived completions — the phrases real users have actually typed before. The log-derived half carries a moderation obligation that is easy to underestimate: echoing a user's own past query back to a different user as a UI suggestion means offensive, private, or misleading logged queries cannot be allowed to surface as suggestions to anyone else.

Entity suggestions draw from the same index's display fields, and they inherit the same exclusions and permissions that index already defined — suggest is a disclosure surface in its own right, not a separate, more permissive channel.

The empty-input state — what a user sees before they type a single character — is a designed moment rather than an afterthought: recent searches and popular queries, at the level of concept, are a product decision an engineer implements deliberately rather than leaving blank by default.

Each of the three suggestion types also implies a different backing query, which is easy to overlook when they all render into the same visual list. A completion is a prefix lookup against a text index. An entity suggestion is closer to a targeted, ID-aware lookup against the catalog's own display fields. A scoped suggestion needs to know about the category structure ahead of time to offer a term-within-a-category row at all. Building all three off one generic prefix query is a shortcut that quietly produces a dropdown where two of the three types feel noticeably worse than the third, because only one of them was actually designed for.

Engineering the keystroke path

Debounce is the first honesty check in the pipeline: not every keystroke deserves its own network request. A short debounce window trades a sliver of perceived latency for a meaningful fraction of request load, and the right window length is a number to tune from measurement, not to guess from folklore.

The stale-response race is one bug to design for in this space, and it is worth walking through as a concrete example. A user types "sho," a request goes out. They keep typing, reaching "shoe," and a second request goes out. If the network is unkind, the response for "sho" can arrive after the response for "shoe" and silently overwrite it in the UI — the dropdown now shows suggestions for a query the user already moved past.

typescript
// In-flight cancellation prevents a stale response
// from overwriting a newer one that already landed.
let controller: AbortController | null = null

async function fetchSuggestions(query: string) {
  controller?.abort()
  controller = new AbortController()
  const res = await fetch(`/suggest?q=${encodeURIComponent(query)}`, { signal: controller.signal })
  return res.json()
}

AbortController-based in-flight cancellation, or response-sequence guarding as an alternative, fixes this cleanly. Cancellation aborts the earlier request before it has completed, and the aborted call rejects with an AbortError DOMException, which the caller should catch and ignore; sequence guarding lets each request finish but discards any response older than the latest one before it reaches the UI.

Client-side caching of prefix results within a session is close to free correctness: the same prefixes recur constantly as a user types and backspaces, and a cached prefix result is trivially still correct a moment later.

The debounce window and the cache interact in a way worth designing for deliberately rather than discovering by accident. A short debounce combined with a session cache means a user typing and then immediately backspacing sees the previous prefix's suggestions reappear instantly from cache rather than triggering a fresh request — which both reduces load and makes the interface feel snappier during the exact interaction pattern (hesitating mid-word, correcting a typo) that a naive request-per-keystroke implementation handles worst.

Keyboard and assistive interaction mechanics are worth naming at the level of concept even though this is not the place for a full accessibility audit: the combobox interaction pattern — arrow-key navigation, selection, and dismissal — has a documented ARIA reference worth citing directly (WAI-ARIA Authoring Practices). Deep accessibility auditing of focus-management edge cases and screen-reader behavior belongs to this site's dedicated accessibility literature.

The suggest quality loop

A serious failure a suggest surface can produce is naming a path to nowhere: the site's own dropdown offering a suggestion that leads to a zero-result results page. That is the system actively recommending a dead end it built itself, not a user mistake — which is why suggest candidates should be validated against the same index they will actually search before they are ever shown.

Suggest telemetry belongs in the same event set the site's broader search analytics already track: suggestion impressions, which ones get picked, and where in the list a picked suggestion sat. A suggestion nobody ever selects is not neutral — it is noise occupying a row that a better suggestion could have used instead.

Freshness has its own obligation here: entity suggestions need to drop delisted products and expired content on the same cadence the underlying search index does. The synchronization discipline that keeps an index current belongs to this topic's index-synchronization coverage; suggest simply inherits it rather than maintaining a separate freshness pipeline.

A few boundaries are worth stating plainly rather than leaving implicit. What the results page does with a chosen suggestion — snippets, sorting, pagination — is the results-page surface's own territory. The zero-results page a suggestion must never lead to is this topic's dedicated recovery coverage. And typo handling inside suggest matching follows the same tolerance rules this topic's typo-and-synonym coverage already defines, rather than inventing a separate fuzzy-matching approach specific to the dropdown.

Project Inquiry