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,21 +3,24 @@ package model_res
import (
"catface/app/model"
"catface/app/model_es"
"time"
)
// BUG 存在 依賴循環
func NewDocResult(doc *model.Doc, doc_es *model_es.Doc) *DocResult {
return &DocResult{
Type: "doc",
Id: doc.Id,
Name: doc.Name,
Content: doc_es.Content,
Type: "doc",
Id: doc.Id,
Name: doc.Name,
Content: doc_es.Content,
UpdatedAt: doc.UpdatedAt,
}
}
type DocResult struct {
Type string `json:"type"`
Id int64 `json:"id"`
Name string `json:"name"`
Content string `json:"content"`
Type string `json:"type"`
Id int64 `json:"id"`
Name string `json:"name"`
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 {
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 {

View File

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