• Elasticsearch 版本控制


    内部版本控制:_version自增长,修改数据后,_version会自动加1
    
    外部版本控制:为了保持_version与外部版本控制的数值一致
    			      使用version_type=external
    			      检查数据当前的version值是否小于请求中的version值
    
    				  
    PUT /library/books/1
    {
      "title": "Elasticsearch: The Definitive Guide",
      "name" : {
        "first" : "Zachary",
        "last" : "Tong"
    
      },
      "publish_date":"2015-02-06",
      "price":"59.99"
    
    }
    
    
    查看数据:
    
    GET /library/books/1
    
    {
      "_index": "library",
      "_type": "books",
      "_id": "1",
      "_version": 1,
      "found": true,
      "_source": {
        "title": "Elasticsearch: The Definitive Guide",
        "name": {
          "first": "Zachary",
          "last": "Tong"
        },
        "publish_date": "2015-02-06",
        "price": "59.99"
      }
    }
    
    修改数据:
    
    POST /library/books/1/_update
    {
      "doc": {
         "price" : 10
      }
    }
    
    此时版本为2:
    
    {
      "_index": "library",
      "_type": "books",
      "_id": "1",
      "_version": 2,
      "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
      }
    }
    
    指定版本去更新:
    POST /library/books/1/_update?version=3
    {
      "doc": {
         "price" : 15
      }
    }
    
    
    {
       "error": {
          "root_cause": [
             {
                "type": "version_conflict_engine_exception",
                "reason": "[books][1]: version conflict, current [2], provided [3]",
                "shard": "3",
                "index": "library"
             }
          ],
          "type": "version_conflict_engine_exception",
          "reason": "[books][1]: version conflict, current [2], provided [3]",
          "shard": "3",
          "index": "library"
       },
       "status": 409
    }

  • 相关阅读:
    Jabref安装及使用教程
    均方误差与均方根误差
    费马大定理
    JabRef设置
    申请内存时底层发生了什么?
    什么是Pipeline?
    基于三维点云场景的语义及实例分割
    华为 MateView 系列显示器新品
    C#-WinForm跨线程修改UI界面
    C# 代码生成二维码方法及代码示例(QRCoder)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349701.html
Copyright © 2020-2023  润新知