Elasticsearch 6.x-学习笔记03 文档的部分更新

一般对应到应用程序中,每次的执行流程基本是这样的:

  1. 应用程序先发起一个get请求,获取到document,展示到前台界面,供用户查看和修改
  2. 用户在前台界面修改数据,发送到后台
  3. 后台代码,会将用户修改的数据在内存中进行执行,然后封装好修改后的全量数据
  4. 然后发送PUT请求,到es中,进行全量替换
  5. es将老的document标记为deleted,然后重新创建一个新的document
post /index/type/id/_update 
{
   "doc": {
      "要修改的少数几个field即可,不需要全量的数据"
   }
}

partial update,看起来很方便的操作,实际内部的原理是什么样子的,然后它的优点是什么

3、上机动手实战演练partial update

PUT /test_index/test_type/10
{
  "test_field1": "test1",
  "test_field2": "test2"
}

POST /test_index/test_type/10/_update
{
  "doc": {
    "test_field2": "updated test2"
  }
}

猜你喜欢

转载自my.oschina.net/nxxYqmvPOvsfH/blog/1795250