Files
kami 14e98334ad query: let her search the live web before she reads the ZIMs
The offline encyclopedia was the only world source, and it reads what was true
when the ZIM was built. A self-hosted SearXNG now asks first and Kiwix is the
fallback for an empty result, an unreachable instance or no line out. Owner's
ruling, 2026-08-02.

internal/websearch is deliberately thin: no rewriter (SearXNG ranks through
real engines, so the Russian question goes out as he asked it), no page fetch,
no cache. It cannot read the store, so only the query string can leave the box.

The personal boundary is unchanged and still sits above this source, so a
question about him is never searched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BFaeSbLMEVG5ey8tejU3y2
2026-08-02 02:24:36 +04:00

42 lines
1.2 KiB
Go

package main
import (
"log"
"time"
"github.com/kami/maven/internal/config"
"github.com/kami/maven/internal/websearch"
)
// searchWiring — the metasearch source, assembled. nil ⇒ off, which is the
// default: no `search` block, no query ever leaves the LAN.
//
// Thinner than kiwixWiring because there is nothing to rewrite. SearXNG ranks
// with real engines, so the question goes out as he asked it, and that is the
// reason this source sits ahead of the ZIMs rather than behind them.
type searchWiring struct {
client *websearch.Client
max int
runes int
}
// wireSearch builds the search client from the `search` block, or returns nil
// when there is none. config.Normalise has already dropped a block with no URL
// and filled the two size defaults, so this does no validation of its own.
func wireSearch(cfg *config.Config) *searchWiring {
if cfg.Search == nil {
return nil
}
sc := cfg.Search
log.Printf("voice: web search at %s (language %q, engines %q)", sc.URL, sc.Language, sc.Engines)
return &searchWiring{
client: websearch.New(sc.URL, websearch.Options{
Language: sc.Language,
Engines: sc.Engines,
Timeout: time.Duration(sc.Timeout),
}),
max: sc.MaxResults,
runes: sc.SnippetRunes,
}
}