Four lines of aliases fixed what neither a reranker nor an LLM rewrite could
In my last post, I tested my local RAG server on 30 questions developers actually asked about the MCP C# SDK, copied from its GitHub issues and discussions. Three of them were never found, by any search mode, because they use words the docs don't:
- Two ask for a "middleware" to count or intercept tool calls. The docs call it filters.
- "In-proc MCP server." is what the docs call the in-memory transport.
A reranker can't fix that, because it only reorders what the search found. Rewriting the question with a local LLM made things worse: qwen2.5 kept the word "middleware" and added generic terms, and the right page came first for 11 to 13 questions instead of 21.
In the comments, @ontomato suggested something simpler: keep an alias list, the developer's word mapped to the docs' word, and apply it at search time without a model in the loop. So I built it.
The alias file
docs-rag-mcp 0.11.0 has a new setting, DOCSRAG_ALIASES, that points to a text file. These four lines are all I used for the SDK docs:
middleware, interceptor = filters in-proc, in-process, in process = in-memory transport load balancer, multiple instances, multi instances = stateless mode http headers, query string = HttpContext When a question contains a word or phrase from the left side, as a whole word, the words on the right are added to it before searching. So "How to implement a tool middleware?" is searched as "How to implement a tool middleware? filters". The embedding, the keyword search and the reranker all see the docs' word. The developer's words stay too, so nothing is lost.
The results
On the 30 real questions, with hybrid search and no reranker:
| Right page first | In the top 20 | MRR | |
|---|---|---|---|
| Without aliases | 21 of 30 | 27 of 30 | 0.75 |
| With aliases | 25 of 30 | 30 of 30 | 0.88 |
Both "middleware" questions and both in-process questions moved to first place. On the 22 questions I wrote myself, every question ranked exactly as before.
Here is how the three fixes compare on the same 30 questions:
| Fix | Right page first |
|---|---|
| None (hybrid search) | 21 |
| Reranking with bge-reranker-v2-m3 | 23 |
| Rewriting with qwen2.5 7B | 11 |
| Four lines of aliases | 25 |
The honest caveat
I wrote the aliases after seeing which questions were missed. So this shows that the mechanism works for words you know people use. It doesn't show how well a list written in advance would guess them.
In practice, that's how you'd use it anyway. You look at the questions your search missed, see that people say "middleware" and your docs say "filters", and add a line. Support tickets, GitHub issues and chat logs are where those words come from.
Why not a bigger model?
A model that knows your docs' vocabulary could do the same thing. But a small local model didn't, and every search would pay for the model call. An alias file costs nothing at search time, you can read it, and you can review it in a pull request like any other code.
The evaluation sets, the alias file and the numbers are in the repo under samples/eval/.