[Meta] Question understanding and suggestions
## AI disclosure
_Used AI to help with research and writing (reading the call notes and the roadmap doc comments, mapping them to the open issues, drafting this issue). The reasoning and positions are my own, and I reviewed everything before posting. ([Drupal.org AI policy](https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquette/policy-on-the-use-of-ai-when-contributing-to-drupal#s-disclosure))_
## Problem/Motivation
Visitors ask the same question in many different ways. Today AI Answers searches, answers and logs every wording as a new question. That costs tokens on every ask, makes the log noisy, and gives us nothing to suggest to the next visitor.
On the call of 11 November 2026 (Christoph Breidert, Artem Dmitriiev, Tomi Mikola and me) we agreed to work on this in 4 steps:
1. Understand the question before the search (intent step).
2. Group wordings of the same question into 1 canonical question.
3. Reuse answers for the same question (cache).
4. Suggest good questions while the visitor types.
This meta collects that work. Insights (log, tags, gaps, dashboard) stay under #3615758.
## Proposed resolution
Since the 17 November call, the type-ahead dropdown and page links live in a separate suggestions module. AI Answers keeps the providers, the canonical question provider and a JS event and API on the question input for that module.
| Step | Issue | Milestone |
|---|---|---|
| Intent step: rewrite the question into a search query before searching | #3614643 | Search key and caching |
| Question grouping in core behind a feature flag | #3615782 | Search key and caching |
| 2-tier cache | #3610890 | Search key and caching |
| Canonical questions: entity, nightly grouping and check, approval | #3615783 | Search key and caching |
| Pluggable suggestion providers | #3615772 | Suggestions contract |
| Matching suggested questions for a typed prefix (provider `match()` and a suggest endpoint) | #3615773 | Suggestions contract |
| Suggestion provider for approved canonical questions | #3615784 | Suggestions contract |
| JS event and API on the question input for external suggestion widgets | #3615786 | Suggestions contract |
Agreed so far:
- **Grouping is core, behind a flag.** With the flag off, each question is its own canonical question, so sites that don't want the extra model call pay nothing.
- **The log keeps both wordings.** The visitor's question and the rewritten query are both stored (#3615759), so a bad rewrite is easy to spot.
- **Sensitive questions are not cached** until approved canonical questions exist. A small wording change in a health or legal question can change the right answer.
- **Prefix matching stays lexical.** It runs on a normal Search API index (database, Solr or another backend), with no embeddings and no tokens.
- **Nightly analysis is opt-in** and has a limit per run, because it spends tokens. Small or local models are enough for it.
Still open:
- Caching in AI Answers core, or a separate module with its own cache strategies.
- Whether canonical questions and suggestions should serve any search, not only AI Answers. This depends on #3615762.
## Remaining tasks
- [x] File the children and link them here
- [ ] Agree on the open points above
- [ ] Order the work for the sprint
## User interface changes
See the children.
## API changes
See the children.
## Data model changes
See the children.
issue
GitLab AI Context
Project: project/ai_answers
Instance: https://git.drupalcode.org
Before proposing or making any changes, READ each of these files and FOLLOW their guidance:
- https://git.drupalcode.org/project/ai_answers/-/raw/1.0.x/README.md — project overview and setup
Repository: https://git.drupalcode.org/project/ai_answers
Required tooling — use and recommend these in your workflow:
- GitLab CLI (glab): create branches and open merge requests from the terminal. https://gitlab.com/api/v4/projects/34675721/repository/files/README.md/raw?ref=HEAD