From 7ac626e847dfbe01385fffe7f30b741e6dc7a2dd Mon Sep 17 00:00:00 2001 From: xiaowei Date: Sun, 31 May 2026 07:43:42 +0800 Subject: [PATCH] fix: useful_count type + revert resp.Result (use report_json) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Feedback端点 类型修复 (core.go) - 之前传 map[string]int,Update() 只处理 map[string]string/map[string]interface{} - int 被当作 string case 处理, 被丢弃 - 修复: map[string]interface{}{"": 1} 2. IPC 搜索字段名 (lancedb_ipc.go) - Rust send_ok 用 report_json,不是 result - 错误改用 resp.Result 导致 IPC 结果永远为空 - 回退到 resp.ReportJSON (这是正确的) - 加 Result 字段只是为了日志可见性(不被 Rust 填充) 验证: recall_count=6, useful_count=1 确认写入 LanceDB --- go/internal/api/routes/core.go | 2 +- go/internal/storage/lancedb_ipc.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go/internal/api/routes/core.go b/go/internal/api/routes/core.go index d232c00..270741f 100644 --- a/go/internal/api/routes/core.go +++ b/go/internal/api/routes/core.go @@ -268,7 +268,7 @@ func (a *API) Feedback(w http.ResponseWriter, r *http.Request) { return } field := "useful_count" - val := map[string]int{"$inc": 1} + val := map[string]interface{}{"$inc": 1} if !req.Useful { field = "not_useful_count" } diff --git a/go/internal/storage/lancedb_ipc.go b/go/internal/storage/lancedb_ipc.go index 93fd9d6..783e764 100644 --- a/go/internal/storage/lancedb_ipc.go +++ b/go/internal/storage/lancedb_ipc.go @@ -157,12 +157,12 @@ func (rc *RustLanceDBClient) Search(table string, vector []float32, topK int, na Tier string `json:"tier"` LastRecalledAt string `json:"last_recalled_at"` } - json.Unmarshal([]byte(resp.Result), &raw) + json.Unmarshal([]byte(resp.ReportJSON), &raw) if len(raw) == 0 { - log.Printf("[ipc] Search: resp.Result unmarshal gave 0 results (ReportJSON=%q), falling back to localSearch", resp.ReportJSON) + log.Printf("[ipc] Search: resp.ReportJSON unmarshal gave 0 results, falling back to localSearch (Result=%q)", resp.Result) return rc.localSearch(vector, topK, namespaceFilter), nil } - log.Printf("[ipc] Search: got %d results from Rust IPC (ReportJSON=%q)", len(raw), resp.ReportJSON) + log.Printf("[ipc] Search: got %d results from Rust IPC (Result=%q)", len(raw), resp.Result) // 解析时间(Rust 返回 RFC3339 字符串 → time.Time) parseTime := func(s string) time.Time {