Knowledge search ranks by how near a chunk's meaning is, not by its place in two lists

Fused by rank, a full-text match on a question's everyday words outvoted a
far nearer meaning: on the PoC, "how much leave do fathers get" found the
annual-leave page before the paternity one (cosine distance 0.44 against
0.25). Now a chunk scores its similarity to the question plus up to 0.3 for
a full-text match, each search brings four times k candidates, the text
search drops Turkish and English stop words, and an operator's search says
when the embedding model did not answer rather than quietly searching text.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-08 15:05:18 +02:00
1 parent 1ec9b83076
commit bc5ee9f3aa
3 files changed
+153 -69

No files matched your search

+7 -3
View File
@@ -450,11 +450,15 @@ func (a *API) kbSearch(w http.ResponseWriter, r *http.Request) {
k = 5
}
q := store.KBSearch{OrgID: c.OrgID, Collections: []store.KBCollection{c}, Text: in.Query, K: k}
// Without the model, the full-text half still answers.
// Said, not swallowed: a search that quietly lost its meaning half
// looks like a collection that does not know the answer.
if a.kb.Embed != nil {
if v, err := a.kb.Embed(r.Context(), c.EmbedModel, in.Query); err == nil {
q.Embeddings = map[string][]float32{c.EmbedModel: v}
v, err := a.kb.Embed(r.Context(), c.EmbedModel, in.Query)
if err != nil {
writeError(w, http.StatusBadGateway, c.EmbedModel+" did not embed the question: "+err.Error())
return
}
q.Embeddings = map[string][]float32{c.EmbedModel: v}
}
hits, err := a.kb.Store.SearchChunks(r.Context(), q)
if err != nil {