Intent-based search
Search in GriMoire is not a single API call. It is a pipeline that understands what the user wants, routes to the right tool, plans query variants, retrieves from multiple sources in parallel, fuses results, and retries with recovery branches when recall is weak.
The full pipeline
Intent routing
Before any search API is called, the system classifies the user's intent using a two-stage approach:
- Keyword matching — catches obvious signals like "email from", "meeting with", "Teams message about"
- ML classification — when keywords are inconclusive, a Nano model classifies the query
| Intent | Tool family | What it searches |
|---|---|---|
| Files and documents | search_sharepoint | SharePoint, OneDrive |
search_emails | Outlook mailbox | |
| People | search_people | Organization directory |
| Calendar | search_calendar | Outlook calendar |
| Teams messages | search_teams | Teams chats and channels |
Asking "find the budget email" searches mail, not SharePoint. Asking "who works on the design team" searches people, not files. Intent routing makes this automatic.
Query planning
For file search, the system runs a first pass where three things happen in parallel:
- Copilot Search receives the raw user query for semantic retrieval
- Copilot Retrieval receives the raw user query for RAG-based retrieval
- Search Intent Planner uses the Nano LLM to produce query variants
Each variant is confidence-gated — only used when the planner's confidence exceeds a threshold. Low-confidence variants are rejected. If the Nano model is unavailable, search still works — the fallback mainly contributes language detection.
SharePoint Search only runs on the first pass if the planner produces a lexical query with sufficient confidence. Otherwise it is skipped.
Multi-source retrieval
| Source | Query used | What it does |
|---|---|---|
| Copilot Search | Raw user query | Semantic search via Copilot APIs |
| Copilot Retrieval | Raw user query | RAG-based retrieval with relevance scores |
| SharePoint Search | Planner lexical query (if available) | Classic lexical search |
Result fusion
The fusion step combines results from all sources using Reciprocal Rank Fusion (RRF):
- Score each item based on its rank position and source weight
- Apply source weights — retrieval is weighted highest, then Copilot Search, then SharePoint
- Deduplicate — the same document may appear across sources; scores are accumulated
- Apply rerank boosts — items found by multiple sources, matching the query language, or containing the query in the title get boosted
- Truncate to the requested result count
Documents found by all three sources tend to rank highest because their scores accumulate across sources.
Recovery branches
After the first pass, the system checks whether the fused result set has at least 5 unique results. If recall is weak, recovery branches run one at a time — each one re-fuses after adding its results:
| Branch | Condition | What it does |
|---|---|---|
| Semantic rewrite | Always, if planner produced one | Runs Copilot Search + Retrieval with a rewritten query |
| Spelling correction | Only if < 5 results after prior branches | Retries with the corrected query |
| Translation fallback | Only if < 5 results and multilingual tenant | Retries in the tenant's primary language |
| Keyword fallback | Only if < 5 results after all above | Runs SharePoint Search with a pure keyword query |
Each branch is deduplicated against already-executed queries so the same search is never run twice.
What the user sees
The search result block shows:
| Field | Value |
|---|---|
| Query | The original user query |
| Results | Fused and ranked result list |
| Total count | Number of unique fused results |
| Sources | Which backends contributed |
| Query variants | Corrections, translations, or keywords used |
Semantic rewrite variants are intentionally hidden from the user-facing display. The search may have used semantic expansion even when the block only shows corrections or translations.
From search to action
Search results become UI blocks. Blocks support drill-down. Drill-down leads to action.
- Search — "Find the latest project recap"
- Recap — GriMoire renders results as a block, the user selects one, and the assistant generates a summary
- Action — "Send the recap by mail"
Search results become the context for recap and action, mediated by the HIE. When the user expresses a multi-step intent in a single sentence — "find the budget docs and send them to the team" — the text path can detect and execute the full chain automatically as a compound workflow.
Worked example
Query: "search for SPFx architecture"
From this point, follow-ups like "summarize document 2" or "send this by email" depend on HIE context tracking and the interaction flow.