使用配置文件和生产索引
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"editor.inlineSuggest.showToolbar": "onHover"
|
||||
"editor.inlineSuggest.showToolbar": "always"
|
||||
}
|
@@ -272,7 +272,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
|
||||
"bool": map[string]interface{}{
|
||||
"must": []map[string]interface{}{
|
||||
{
|
||||
"query_string": map[string]string{"query": "City:" + args.Text},
|
||||
"query_string": map[string]string{"query": "text:" + args.Text},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -182,6 +182,7 @@ func main() {
|
||||
config := viper.GetViper()
|
||||
|
||||
models.InitConfig(config)
|
||||
models.ZincInit()
|
||||
|
||||
mysqlConnection.Init()
|
||||
milvusConnection.Init()
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user