feat:优化项目信息

This commit is contained in:
henry
2022-02-08 16:11:59 +08:00
parent 166753d811
commit 17dd9bea7f
7 changed files with 109 additions and 21 deletions

View File

@ -27,11 +27,19 @@ func Create(index, id string, body []byte) error {
}
// Update 更新操作
func Update(index, id string, body []byte) error {
func Update(index, id string, params map[string]interface{}) error {
scriptStr := ""
for k := range params {
scriptStr += "ctx._source." + k + " = params." + k + ";"
}
script := elastic.NewScript(scriptStr).Params(params)
_, err := client.Update().
Index(index).
Id(id).
Doc(string(body)).
Script(script).
//Doc(string(body)).
Do(context.Background())
return err
}