← Lessons

quiz vs the machine

Gold1390

System Design

Query Understanding and Synonyms

Rewriting and enriching a query so it matches what the user really meant.

5 min read · core · beat Gold to climb

Bridging intent and index

The exact words a user types rarely match the index perfectly. Query understanding transforms the raw query into a richer form that better expresses intent before retrieval runs.

Common transformations

  • Synonym expansion adds equivalent terms, so a search for tv also matches television.
  • Spelling correction fixes likely typos using the index vocabulary and edit distance.
  • Entity recognition spots a brand, place, or category and routes the query or applies a filter.
  • Intent classification decides whether the query is navigational, informational, or transactional and shapes the result mix.

Where synonyms apply

Synonyms can be expanded at index time, writing all variants into the postings, or at query time, expanding the query as it runs. Index time is faster at query time but the synonym list is frozen into the data, so changes require reindexing. Query time is flexible but adds work per search.

A subtle risk is over expansion: adding too many synonyms broadens recall but drags in irrelevant results, so expansion should be weighted and curated rather than indiscriminate.

Key idea

Query understanding rewrites and enriches the query with synonyms, spelling fixes, and intent, choosing index time or query time expansion and curating it to avoid over broadening.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the trade off of expanding synonyms at index time?

2. What is the risk of over expanding synonyms?