MCPcopy Create free account
hub / github.com/53AI/53AIHub / Search

Function Search

api/controller/search.go:14–47  ·  view source on GitHub ↗

Search 统一搜索接口

(c *gin.Context)

Source from the content-addressed store, hash-verified

12
13// Search 统一搜索接口
14func Search(c *gin.Context) {
15 eid := config.GetEID(c)
16
17 // 解析请求体
18 var req rag.SearchRequest
19 if err := c.ShouldBindJSON(&req); err != nil {
20 c.JSON(http.StatusBadRequest, gin.H{
21 "success": false,
22 "message": "请求参数错误",
23 "error": err.Error(),
24 })
25 return
26 }
27
28 // 创建搜索服务
29 searchService := rag.NewSearchService(model.DB)
30
31 // 执行搜索
32 response, err := searchService.Search(eid, &req, nil)
33 if err != nil {
34 c.JSON(http.StatusInternalServerError, gin.H{
35 "success": false,
36 "message": "搜索失败",
37 "error": err.Error(),
38 })
39 return
40 }
41
42 c.JSON(http.StatusOK, gin.H{
43 "success": true,
44 "message": "搜索成功",
45 "data": response,
46 })
47}
48
49// VectorSearch 向量搜索
50func VectorSearch(c *gin.Context) {

Callers

nothing calls this directly

Calls 3

SearchMethod · 0.95
GetEIDMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected