feat(model_res): 为 DocResult 结构体添加 UpdatedAt 字段
- 在 DocResult 结构体中添加 UpdatedAt 字段,类型为 *time.Time - 更新 NewDocResult 函数,包含 UpdatedAt 字段 - 修改 DocCurd 服务,获取文档时包含 updated_at 字段 - 启动 ElasticSearch 服务
This commit is contained in:
		
							parent
							
								
									85b4b61a32
								
							
						
					
					
						commit
						2645d4265a
					
				@ -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"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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 {
 | 
			
		||||
 | 
			
		||||
@ -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: ""
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user