Sub topic 7
From a Question to Search Queries
Assume you understand basic web crawling and indexing, HTTP requests, and the general role of a large language model. This chapter focuses on what happens after a user asks an answer engine a question.
Why answer engines rewrite questions
A user question is often too broad, conversational, or incomplete for direct retrieval. An answer engine first interprets the question and creates one or more search queries. This process is called query rewriting. A rewritten query is a search-oriented version of the user's original wording.
For example, a user might ask:
> Can I use short-lived access tokens with a command-line tool?
The engine may identify several search needs:
short-lived access tokens command-line toolCLI token refresh patternOAuth device authorization flow command lineaccess token expiration handling documentation
The engine can run these searches separately and combine their results. Multiple searches help cover different terms, sources, and interpretations.
The rewriting process
A typical process looks like this:
The engine may extract:
- Intent: what the user wants to accomplish, such as comparing options or solving an error.
- Entities: products, protocols, companies, or technologies mentioned in the question.
- Constraints: dates, programming languages, regions, versions, or user roles.
- Missing context: details that the user did not state but that affect the answer.
- Expected evidence: documentation, tutorials, specifications, or recent announcements.
It may also split a complex question into subquestions. A question about choosing a database might become searches for performance, pricing, backup support, and operational limits.
One question can produce several retrieval paths
Query rewriting is not always a single transformation. An engine can issue searches in parallel, then compare the results. It may use one query for exact terminology, another for related language, and another for a known product or domain.
| User need | Possible rewritten query |
|---|---|
| Learn a mechanism | `how OAuth refresh tokens work` |
| Find current limits | `OAuth provider refresh token expiration 2026` |
| Locate authoritative evidence | `site:example.com refresh token documentation` |
The engine can refine later searches based on early results. If the first results reveal a specific error name or product version, that term may appear in a follow-up query.
What this means for page authors
Write for the underlying question, not only for one exact keyword phrase. State the main problem and its answer directly. Include the terms that knowledgeable readers use, along with their common alternatives. Separate related subquestions into clear sections.
A self-contained passage gives the retrieval system enough context to understand what the passage means. For example, “It expires after one hour” is difficult to use without a nearby subject. “The access token expires after one hour” is easier to retrieve and cite.
Query rewriting improves discovery, but it does not guarantee that a particular page will be selected. Retrieval ranking, passage quality, authority, freshness, and the engine's current sources still affect the result.
Exercise
A user asks, “What is the safest way to rotate database credentials without downtime?” Name two useful rewritten queries.
Show answer
Examples include “zero-downtime database credential rotation” and “dual credentials secret rotation deployment pattern.”