Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsStale ¶
IsStale reports whether doc's current content hash differs from a previously stored hash — the trigger for rebuilding the dedup index (spec: Error Handling — wiki/index staleness).
func SaveToFile ¶
Types ¶
type Index ¶
type Index struct {
Docs []Doc
Vocab map[string]int // term -> index into each vector
Vectors [][]float64 // one vector per Doc, same order as Docs
Links map[string][]string // extracted co-mention edges: path -> paths mentioned by that doc
}
Index is a TF-IDF vector search index over wiki documents. This is a deliberate v1 simplification of the spec's "embeddings index": the spec named semantic search as the goal but did not specify an embedding provider, and adding one would mean either an external API dependency (contradicting "Golem stores no credentials") or an arbitrary vendor choice. TF-IDF cosine similarity gets meaningfully better-than-grep retrieval with zero network calls and zero credentials — pure Go, no cgo.
func EnsureIndex ¶
EnsureIndex is the one place staleness, rebuild, and search come together: it loads the on-disk index if it's still fresh, or rebuilds it from current wiki content if it's missing or any document's hash has changed since the index was last saved (spec: Error Handling).
func LoadFromFile ¶
func (*Index) Search ¶
Search returns the topK documents most similar to query, ranked highest score first.
func (*Index) SearchExpanded ¶
SearchExpanded returns the topK TF-IDF matches, then appends any docs that those matches link to (one hop only) and are not already in the direct results. Linked results score at half the referring doc's score so they always sort after direct matches. The Via field on each linked Match names the doc that mentioned it, so callers can show provenance.