zoukankan      html  css  js  c++  java
  • (十三)Batch Processing

    In addition to being able to index, update, and delete individual documents, Elasticsearch also provides the ability to perform any of the above operations in batches using the _bulk API. This functionality is important in that it provides a very efficient mechanism to do multiple operations as fast as possible with as few network roundtrips as possible.

    批处理过程 除了能够索引,更新和删除单个文档之外,Elasticsearch还提供了使用_bulk API批量执行上述任何操作的功能。此功能非常重要,因为它提供了一种非常有效的机制,可以尽可能快地执行多个操作,并尽可能少地进行网络往返。
     
     As a quick example, the following call indexes two documents (ID 1 - John Doe and ID 2 - Jane Doe) in one bulk operation:
    作为一个简单示例,以下调用在一个批量操作中索引两个文档(ID 1 - John Doe和ID 2 - Jane Doe):
    curl -X POST "localhost:9200/customer/_doc/_bulk?pretty" -H 'Content-Type: application/json' -d'
    {"index":{"_id":"1"}}
    {"name": "John Doe" }
    {"index":{"_id":"2"}}
    {"name": "Jane Doe" }
    '
    使用postMan调用时
    {"index":{"_id":"1"}}
    {"name": "John Doe" }
    //此处必须换行 {"index":{"_id":"2"}} {"name": "Jane Doe" }
    //此处必须换行

    This example updates the first document (ID of 1) and then deletes the second document (ID of 2) in one bulk operation:

    此示例更新第一个文档(ID为1),然后在一个批量操作中删除第二个文档(ID为2):
    curl -X POST "localhost:9200/customer/_doc/_bulk?pretty" -H 'Content-Type: application/json' -d'
    {"update":{"_id":"1"}}
    {"doc": { "name": "John Doe becomes Jane Doe" } }
    {"delete":{"_id":"2"}}
    '
    使用postMan调用时
    与上面一样,需要通过换行分隔

    Note above that for the delete action, there is no corresponding source document after it since deletes only require the ID of the document to be deleted.

    请注意,对于删除操作,之后没有相应的源文档,因为删除只需要删除文档的ID。
     
     The Bulk API does not fail due to failures in one of the actions. If a single action fails for whatever reason, it will continue to process the remainder of the actions after it. When the bulk API returns, it will provide a status for each action (in the same order it was sent in) so that you can check if a specific action failed or not.
      Bulk API不会因其中一个操作失败而失败。如果单个操作因任何原因失败,它将继续处理其后的其余操作。批量API返回时,它将为每个操作提供一个状态(按照发送的顺序),以便您可以检查特定操作是否失败。
     
  • 相关阅读:
    这些HTML、CSS知识点,面试和平时开发都需要 No1-No4(知识点:HTML、CSS、盒子模型、内容布局)
    skywalking在 .net Framework客户端使用
    websoket的扫码登陆简单用法
    微信授权登陆nginx代理
    本地下载文件的方法(兼容下载图片和视频)
    Vue-给对象新增属性(使用Vue.$set())
    浏览器解析URL的过程
    promise es6,es7
    filter全局方法的写法
    监听滚动条
  • 原文地址:https://www.cnblogs.com/shuaiandjun/p/10272878.html
Copyright © 2011-2022 走看看