feat(kb): 大文档正文存 MinIO(PG 只留元数据+预览+对象键)
超过阈值(8000 字)的正文落对象存储,彻底解决十几万字文件塞 PG 的问题。 - internal/blob:minio-go 封装 Store(Open/Put/Get/Delete + Ready 降级);连不上则降级内联。 - docker-compose:milvus-minio 暴露 9000 端口供网关用作文档对象存储(bucket sundynix-docs)。 - main/router/handler:注入 blob.Store(env MINIO_*,默认 localhost:9000 minioadmin)。 - runIngest:size>8000 且 MinIO 可用 → 正文 Put 到 owner/kb/name,PG content 置空仅存 object_key+preview+size;否则内联。SaveDoc 改为按全文显式传 preview(offload 后内联为空也有预览)。 - KbDoc:object_key 非空时从 MinIO 取回全文。 验证:入 12182 字笔记 → PG content_len=0、object_key=wt/default/超大文件测试、preview 非空、 size=12182;/kb/doc 取回完整 12182 字(来自 MinIO);6321 字的仍内联(object_key 空)。 列表只读元数据+预览。gateway build 通过。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -121,13 +121,11 @@ func docHead(s string, n int) string {
|
||||
}
|
||||
|
||||
// SaveDoc 写入/更新一份文档(owner+kb+name 唯一,重名覆盖)。
|
||||
// 同时维护 size 与 preview(列表只读它们,不拉全文)。content 入参为内联正文;
|
||||
// objectKey 非空表示正文已转 MinIO(此时 content 传空)。
|
||||
func (p *Postgres) SaveDoc(ctx context.Context, owner, kb, name, content, objectKey string, size int) error {
|
||||
// content 为内联正文(大文档转 MinIO 时传空 + objectKey);preview/size 由调用方按全文给出。
|
||||
func (p *Postgres) SaveDoc(ctx context.Context, owner, kb, name, content, objectKey string, size int, preview string) error {
|
||||
if p.db == nil {
|
||||
return nil
|
||||
}
|
||||
preview := docHead(content, 500)
|
||||
return p.db.WithContext(ctx).Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "owner"}, {Name: "kb"}, {Name: "name"}},
|
||||
DoUpdates: clause.Assignments(map[string]any{"content": content, "object_key": objectKey, "size": size, "preview": preview, "updated_at": time.Now()}),
|
||||
|
||||
Reference in New Issue
Block a user