纯手记,请绕道
Nested修改部分字段
POST hellov1/_update/1
{
"script": {
"lang": "painless",
"source": """
for (x in ctx._source.helloSonESList) {
if (x.name == "son11") {
x.name = "son11111";
}
}
"""
}
}
或
POST hellov1/_update_by_query
{
"query": {
"match": {
"id": 2
}
},
"script": {
"lang": "painless",
"source": """
ctx._source.helloSonESList.remove(0)
"""
}
}
Nested添加
POST hellov1/_update/1
{
"script": {
"lang": "painless",
"source": """
ctx._source.helloSonESList.add(params.newOne)
""",
"params": {
"newOne":{
"name": "son33",
"pid": 1,
"id": 3
}
}
}
}
Nested删除
POST hellov1/_update/1
{
"script": {
"lang": "painless",
"source": """
ctx._source.helloSonESList.removeIf(x -> x.id == 3)
"""
}
}