所以,我终于使这件事起作用了。这是我用来完成代码的代码。
update, err := client.Update().Index("test3").Type("user").Id("2").Doc(map[string]interface{}{"location": message}).Do()fmt.Println("updated id: ", update.Id)这对我来说很好。
我尝试了另一种方法来更新它,但是它不起作用。我将其张贴在这里,以便可以查看和检查。是这样的。
update := client.Update().Index("test3").Type("user").Id("2").script(elastic.Newscript("ctx._source.location = loc").Params(map[string]interface{}{"loc": message}).Lang("groovy"))fmt.Println("updated id: ", update.Id)希望这对某人有帮助!



