Query Operation#
Think of it like a Library with a Card Catalog#
You walk into a library and ask: "Where can I learn about public transport in Jakarta?"
The librarian doesn't read every book from cover to cover. They go to the card catalog (the _index.md and keyword search) and find three relevant cards:
- "TransJakarta busway"
- "MRT Jakarta"
- "Commuter line KRL"
Each card tells you: which shelf, how long since it was updated, whether it's a short note or a long article.
The librarian brings you those three books. You read them — or in our case, the LLM reads them — and synthesizes an answer:
"Jakarta's public transport has three main systems. The busway (TransJakarta) covers the most ground. Here are routes that pass Pasar Baru..."
Each fact is cited with backlinks — like [[wikilinks]] footnotes pointing to the exact card you used.
The Actual Flow#
You ask: "How do busway routes work?"
→ query.py searches ~/llm-wiki/wiki/ for matching terms
→ scores pages by: title (10x), tags (5x), body mentions (0.5x)
→ returns top 5 as JSON with full content
→ Agent (LLM) reads the matched pages
→ Synthesizes answer with [[wikilink]] citations
The Key Insight: This Is Not a Chatbot Answer#
When you query ChatGPT directly, the answer comes from its training data — you have no idea which source it used.
When you query the LLM Wiki:
- Every fact traces back to a specific wiki page
- Every wiki page has a source field: the original URL or conversation
- You can follow the breadcrumbs all the way back to the raw material
It's a chain of custody for knowledge. That's what makes it trustworthy.
What Makes a Good Query#
- Use the exact terms you'd expect in page titles: "transjakarta" not "that bus thing"
- The search is dumb keyword matching — it rewards wiki pages that use the same vocabulary
- If query returns nothing useful, the knowledge probably isn't in the wiki yet → that's a signal to INGEST a source about that topic
Why This Beats a File Search#
Plain grep gives you raw text lines with no context. The query script:
- Ranks results by relevance
- Returns whole pages with frontmatter (tags, source, freshness)
- Feeds structured JSON to the LLM for better synthesis
Remember: Every answer is only as good as the wiki behind it. Empty results mean you need more sticky notes on the wall.