feat(model_res): 为 DocResult 结构体添加 UpdatedAt 字段

- 在 DocResult 结构体中添加 UpdatedAt 字段,类型为 *time.Time
- 更新 NewDocResult 函数,包含 UpdatedAt 字段
- 修改 DocCurd 服务,获取文档时包含 updated_at 字段
- 启动 ElasticSearch 服务
This commit is contained in:
Havoc412 2024-11-20 03:28:56 +08:00
parent 85b4b61a32
commit 2645d4265a
3 changed files with 13 additions and 10 deletions

View File

@ -3,6 +3,7 @@ package model_res
import ( import (
"catface/app/model" "catface/app/model"
"catface/app/model_es" "catface/app/model_es"
"time"
) )
// BUG 存在 依賴循環 // BUG 存在 依賴循環
@ -12,6 +13,7 @@ func NewDocResult(doc *model.Doc, doc_es *model_es.Doc) *DocResult {
Id: doc.Id, Id: doc.Id,
Name: doc.Name, Name: doc.Name,
Content: doc_es.Content, Content: doc_es.Content,
UpdatedAt: doc.UpdatedAt,
} }
} }
@ -20,4 +22,5 @@ type DocResult struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Content string `json:"content"` Content string `json:"content"`
UpdatedAt *time.Time `json:"updated_at"`
} }

View File

@ -29,7 +29,7 @@ func (d *DocCurd) TopK(embedding []float64, k int) (temp []model_res.DocResult,
for _, doc := range docs_es { for _, doc := range docs_es {
ids = append(ids, doc.Id) ids = append(ids, doc.Id)
} }
docs := d.doc.ShowByIds(ids, "id", "name") docs := d.doc.ShowByIds(ids, "id", "name", "updated_at")
// 装载 // 装载
for _, doc := range docs { for _, doc := range docs {

View File

@ -173,7 +173,7 @@ QiNiu:
SecretKey: "UP5-GmSmAYNbMlSb6LYLuKZ-fT35nlEzGvOKKm9S" SecretKey: "UP5-GmSmAYNbMlSb6LYLuKZ-fT35nlEzGvOKKm9S"
ElasticSearch: ElasticSearch:
Start: 0 # 0 不启动1 启动 Start: 1 # 0 不启动1 启动
Addr: "http://localhost:9200" Addr: "http://localhost:9200"
UserName: "elastic" UserName: "elastic"
Password: "" Password: ""