1
This commit is contained in:
parent
b982e32d6d
commit
0e6e2ca053
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/linux/
|
||||
@ -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"))
|
||||
|
||||
14
main.go
14
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)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user