Bulk 端点
POST /_bulk
{
"delete": {
"_index": "website",
"_type": "blog",
"_id": "123"
}
}
省略 type、index
POST /my_store/products/_bulk
{"index":{"_id":1}}
{"price":10,"productID":"XHDK-A-1293-#fJ3"}
{"index":{"_id":2}}
{"price":20,"productID":"KDKE-B-9947-#kL5"}
{"index":{"_id":3}}
{"price":30,"productID":"JODL-X-1937-#pV7"}
{"index":{"_id":4}}
{"price":30,"productID":"QQPX-R-3956-#aD8"}
_delete_by_query, _update_by_query
必须能查询到才能更新
POST /twitter/_update_by_query
{
"script": {
"source": "ctx._source.likes++",
"lang": "painless"
},
"query": {
"term": {
"user": "kimchy"
}
}
}
POST /twitter/_update_by_query
{
"script": {
"source": "ctx._source.name = params.new_name",
"params": {
"new_name": "tome"
},
"lang": "painless"
}
}
script 错误示例(低版本可行):
{
"script": {
"source": "ctx._source['xxx']='xxxxx'",
"lang": "painless"
}
}
_update
脚本方式更新:
POST /website/blog/1/_update?pretty
{
"script" : "ctx._source.views+=1"
}
指定字段更新:
POST /website/blog/1/_update?pretty
{
"doc" : {
"tags" : ["testing"],
"views": 0
}
}