ElasticSearch update

官網文檔地址

1 - 單個更新指定字段

update table set first_time = 1 where id=1
POST test/doc/1/_update
{
  "doc": {
    "first_time": 1
  }
}

2 - 批量更新字段

update table set first_time = last_time where first_time=0 and last_time !=0
POST test/_update_by_query
{
  "script": {
    "source": "ctx._source.first_time=ctx._source.last_time"
  },
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "first_time": 0
          }
        }
      ],
      "must_not": [
        {
          "term": {
            "last_time": 0
          }
        }
      ]
    }
  }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章