使用配置文件和生产索引

This commit is contained in:
2023-12-08 23:20:11 +08:00
parent b4ce9846bf
commit e5017fdcdb
4 changed files with 16 additions and 29 deletions

View File

@@ -11,21 +11,19 @@ import (
"net/url"
)
// 查询参数
//type Query struct {
// Query struct {
// Bool struct {
// Must []struct {
// QueryString struct {
// Query string `json:"query"`
// } `json:"query_string"`
// } `json:"must"`
// } `json:"bool"`
// } `json:"query"`
// Sort []string `json:"sort"`
// From int `json:"from"`
// Size int `json:"size"`
//}
var (
user string
password string
index string
zincHost string
)
func ZincInit() {
user = config.GetString("zincsearch.user")
password = config.GetString("zincsearch.password")
index = config.GetString("zincsearch.index")
zincHost = config.GetString("zincsearch.host")
}
// 返回结果
type Response struct {
@@ -111,12 +109,6 @@ func (res Response) ToIDList(first, last int, after, before string) (id_list []s
}
func ZincSearch(query map[string]interface{}) (rest Response, err error) {
const (
user = "admin"
password = "Complexpass#123"
index = "olympics"
zincHost = "https://zincsearch.gameui.net"
)
bas64encodedCreds := base64.StdEncoding.EncodeToString([]byte(user + ":" + password))
zincURL := zincHost + "/es/" + index + "/_search"
queryBytes, _ := json.Marshal(query)
@@ -159,12 +151,6 @@ func ZincSearch(query map[string]interface{}) (rest Response, err error) {
}
func ZincPut(data map[string]interface{}) (err error) {
const (
user = "admin"
password = "Complexpass#123"
index = "olympics"
zincHost = "https://zincsearch.gameui.net"
)
bas64encodedCreds := base64.StdEncoding.EncodeToString([]byte(user + ":" + password))
zincURL := zincHost + "/api/" + index + "/_doc"
queryBytes, _ := json.Marshal(data)