From 0e6e2ca053f82705113227e93c71a688adebc062 Mon Sep 17 00:00:00 2001 From: 97694731 <97694731@qq.com> Date: Sat, 28 Feb 2026 15:00:08 +0800 Subject: [PATCH] 1 --- .gitignore | 1 + es/es_search.go | 12 +++++++++--- main.go | 14 +++++++------- 3 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc49205 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/linux/ diff --git a/es/es_search.go b/es/es_search.go index 069fd12..e74b38e 100644 --- a/es/es_search.go +++ b/es/es_search.go @@ -1834,7 +1834,7 @@ func (svc *ESSearchService) BatchGetBookBaseInfoES(c *gin.Context) ([]ESBook, in }, "sort": sort, "_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 } - isbnList := make([]map[string]string, 0, len(list)) + isbnList := make([]map[string]interface{}, 0, len(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")) diff --git a/main.go b/main.go index 200e6a9..eef30d8 100644 --- a/main.go +++ b/main.go @@ -174,17 +174,17 @@ func main() { //) /** 新ES,任务2 **/ - esClient, err := es.NewESClient( - []string{"http://localhost:9200"}, - "elastic", - "zDzSXel3PFwx9=6Ybmqv", - ) - /** ES2 本地测试 **/ //esClient, err := es.NewESClient( - // []string{"http://36.212.1.63:9200"}, + // []string{"http://localhost:9200"}, // "elastic", // "zDzSXel3PFwx9=6Ybmqv", //) + /** ES2 本地测试 **/ + esClient, err := es.NewESClient( + []string{"http://36.212.1.63:9200"}, + "elastic", + "zDzSXel3PFwx9=6Ybmqv", + ) if err != nil { log.Fatalf("初始化 ES 客户端失败: %s", err) }