Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

45_Partial_update 的错误 #594

Open
johnnico233 opened this issue Aug 3, 2019 · 1 comment
Open

45_Partial_update 的错误 #594

johnnico233 opened this issue Aug 3, 2019 · 1 comment

Comments

@johnnico233
Copy link

johnnico233 commented Aug 3, 2019

“我们也可以通过使用脚本给 tags 数组添加一个新的标签。在这个例子中,我们指定新的标签作为参数,而不是硬编码到脚本内部。 这使得 Elasticsearch 可以重用这个脚本,而不是每次我们想添加标签时都要对新脚本重新编译:”

这一段中的代码:

POST /website/blog/1/_update { "script" : "ctx._source.tags+=new_tag", "params" : { "new_tag" : "search" } }

在7.2无法执行,需要修改成以下代码才可以执行
POST /website/blog/1/_update { "script" : { "inline":"ctx._source.tags+=params.new_tag", "params" : { "new_tag" : "search" } } }

@antelop304
Copy link

7.3.0,需要修改为:
POST /website/blog/1/_update?pretty
{
"script" : {
"inline":"ctx._source.tags.add(params.new_tag)",
"params" : {
"new_tag" : "search"
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants