美文网首页
Elasticsearch之Update

Elasticsearch之Update

作者: DONG999 | 来源:发表于2018-06-04 18:07 被阅读0次

Painless script可以用来更新或新增field到一个document中, 下面是范例代码:

带参数更新

POST v2_tmm/doc/6SGjpWMBOloH49RB8o2r/_update
 {
   "script": {
     "lang": "painless",
     "source": "ctx._source.vid=333; ctx._source.first=params.first",
     "params": {
       "first": "aln",
       "last": "zhou"
     }
   }
   
 }

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html

更新查询后的记录:

POST base_data/_update_by_query
{
  "script": {
    "source": "ctx._source.userid='updateduser'",
    "lang": "painless"
  },
  "query": {
        "match" : {
            "userid" : ""
        }
    }
}

相关文章

网友评论

      本文标题:Elasticsearch之Update

      本文链接:https://www.haomeiwen.com/subject/fxmysftx.html