使用配置文件和生产索引
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{}{
|
"bool": map[string]interface{}{
|
||||||
"must": []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()
|
config := viper.GetViper()
|
||||||
|
|
||||||
models.InitConfig(config)
|
models.InitConfig(config)
|
||||||
|
models.ZincInit()
|
||||||
|
|
||||||
mysqlConnection.Init()
|
mysqlConnection.Init()
|
||||||
milvusConnection.Init()
|
milvusConnection.Init()
|
||||||
|
@@ -11,21 +11,19 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 查询参数
|
var (
|
||||||
//type Query struct {
|
user string
|
||||||
// Query struct {
|
password string
|
||||||
// Bool struct {
|
index string
|
||||||
// Must []struct {
|
zincHost string
|
||||||
// QueryString struct {
|
)
|
||||||
// Query string `json:"query"`
|
|
||||||
// } `json:"query_string"`
|
func ZincInit() {
|
||||||
// } `json:"must"`
|
user = config.GetString("zincsearch.user")
|
||||||
// } `json:"bool"`
|
password = config.GetString("zincsearch.password")
|
||||||
// } `json:"query"`
|
index = config.GetString("zincsearch.index")
|
||||||
// Sort []string `json:"sort"`
|
zincHost = config.GetString("zincsearch.host")
|
||||||
// From int `json:"from"`
|
}
|
||||||
// Size int `json:"size"`
|
|
||||||
//}
|
|
||||||
|
|
||||||
// 返回结果
|
// 返回结果
|
||||||
type Response struct {
|
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) {
|
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))
|
bas64encodedCreds := base64.StdEncoding.EncodeToString([]byte(user + ":" + password))
|
||||||
zincURL := zincHost + "/es/" + index + "/_search"
|
zincURL := zincHost + "/es/" + index + "/_search"
|
||||||
queryBytes, _ := json.Marshal(query)
|
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) {
|
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))
|
bas64encodedCreds := base64.StdEncoding.EncodeToString([]byte(user + ":" + password))
|
||||||
zincURL := zincHost + "/api/" + index + "/_doc"
|
zincURL := zincHost + "/api/" + index + "/_doc"
|
||||||
queryBytes, _ := json.Marshal(data)
|
queryBytes, _ := json.Marshal(data)
|
||||||
|
Reference in New Issue
Block a user