This commit is contained in:
97694731 2026-02-28 15:00:08 +08:00
parent b982e32d6d
commit 0e6e2ca053
3 changed files with 17 additions and 10 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/linux/

View File

@ -1834,7 +1834,7 @@ func (svc *ESSearchService) BatchGetBookBaseInfoES(c *gin.Context) ([]ESBook, in
}, },
"sort": sort, "sort": sort,
"_source": map[string]interface{}{ "_source": map[string]interface{}{
"includes": []string{"isbn"}, // 排除content字段 "includes": []string{"isbn", "author", "book_name", "fix_price", "publisher"},
}, },
} }
@ -1936,9 +1936,15 @@ func (svc *ESSearchService) BatchGetBookBaseInfoESHandler(c *gin.Context) {
return return
} }
isbnList := make([]map[string]string, 0, len(list)) isbnList := make([]map[string]interface{}, 0, len(list))
for _, book := range list { for _, book := range list {
isbnList = append(isbnList, map[string]string{"isbn": book.ISBN}) isbnList = append(isbnList, map[string]interface{}{
"isbn": book.ISBN,
"book_name": book.BookName.Value,
"fix_price": float64(book.FixPrice),
"author": book.Author,
"publisher": book.Publisher,
})
} }
page, _ := strconv.Atoi(c.DefaultQuery("page", "1")) page, _ := strconv.Atoi(c.DefaultQuery("page", "1"))

14
main.go
View File

@ -174,17 +174,17 @@ func main() {
//) //)
/** 新ES任务2 **/ /** 新ES任务2 **/
esClient, err := es.NewESClient(
[]string{"http://localhost:9200"},
"elastic",
"zDzSXel3PFwx9=6Ybmqv",
)
/** ES2 本地测试 **/
//esClient, err := es.NewESClient( //esClient, err := es.NewESClient(
// []string{"http://36.212.1.63:9200"}, // []string{"http://localhost:9200"},
// "elastic", // "elastic",
// "zDzSXel3PFwx9=6Ybmqv", // "zDzSXel3PFwx9=6Ybmqv",
//) //)
/** ES2 本地测试 **/
esClient, err := es.NewESClient(
[]string{"http://36.212.1.63:9200"},
"elastic",
"zDzSXel3PFwx9=6Ybmqv",
)
if err != nil { if err != nil {
log.Fatalf("初始化 ES 客户端失败: %s", err) log.Fatalf("初始化 ES 客户端失败: %s", err)
} }