feat:优化项目信息
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user