Elasticsearch _update_by_query (二)
接上用script update by query
按条件更新
POST book/_update_by_query
{"script": {
"lang": "painless",
"source": """
ctx._source.numb="2"
"""
},
"query": {
"term": {
"keyword": {
"value": "oracle"
}
}
}
}
按ID更新,重命名字段numb为text_entry
POST book/_update/2
{
"script": {
"lang": "painless",
"source": """
String numb = ctx._source.numb;
ctx._source.remove('numb');
ctx._source.text_entry = numb;
"""
}
}
全部文档增加字段commet
POST book/_update_by_query
{"script": {
"lang": "painless",
"source": """
ctx._source.commet="welcome to commets"
"""
},
"query": {
"match_all": {}
}
}
删除条件
POST book/_delete_by_query
{
"query":{
"bool": {
"should":{
"term":{"keyword.keyword": "oracle"}
}
}
}
}
每天进步一点点,多思考,多总结
版权声明:本文为CNblog博主「zaituzhong」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。