現用es版本6.1.2(ps:從官網不知道怎麼的點到了 es2.0的文檔,找到的api一個都用不了,一把辛酸淚,記錄一下 常用的api)
粘貼不能直接使用,還得去格式。。。。
1.批量更新(根據查詢條件更新數據)
post /goods/_update_by_query
{
"query": {
"term": {
"type": "*****"
}
},
"script": {
"source": "ctx._source.goodsDelete=0"
}
}
2.刪除指定文檔某列
post /goods/doc/shop_goods_65/_update
{
"script": "ctx._source.remove('goodsDelete')"
}
3.批量刪除(根據指定條件)
post /goods/_delete_by_query
{
"query": {
"match": {
"goodsType": "0"
}
}
}
4.批量條件查詢更新
post goods/_update_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"type": "*****"
}
},
{
"range": {
"createTime": {
"lt": ******
}
}
}
]
}
},
"script": {
"source": "ctx._source.id='*****'+ctx._source.userOrderId"
}
}