zoukankan      html  css  js  c++  java
  • ELK学习总结(2-4)bulk 批量操作-实现多个文档的创建、索引、更新和删除

    bulk 批量操作-实现多个文档的创建、索引、更新和删除

    ------------------------------------------------------------------------------ 

    1、命令格式

    {action:{metadata}}

    {request body}

    {action:{metadata}}

    {request body}

    其中,action的值有 createindexupdatedelete

    create:当文档不存在时创建之

    index:创建或替换已有文档

    update:局部更新文档

    delete:删除一个文档

     

    例如:{“delete”:{“_index”:"library","_type":"books","_id":"1"}} 

    ------------------------------------------------------------------------------ 

    2、举例如下

    请求命令:

    POST /library/books/_bulk

    {"index":{"_id":1}}

    {"title":"The Elasticsearch cook book","price":5}

    {"index":{"_id":2}}

    {"title":"Thinking in python","price":25}

    {"index":{"_id":3}}

    {"title":"Thinking in java","price":15}

    执行结果:

    {

        “took”:528,

        “errors”:false,

        "items":

        {

             "index":{

                  "_index":"library",

                  "_type":"book",

                  "_id":"1",

                  "_version":1,

                  "status":201

                  }

              },

             "index":{

                  "_index":"library",

                  "_type":"book",

                  "_id":"2",

                  "_version":1,

                  "status":201

                  }

              },

             "index":{

                  "_index":"library",

                  "_type":"book",

                  "_id":"3",

                  "_version":1,

                  "status":201

                  }

              },

             "index":{

                  "_index":"library",

                  "_type":"book",

                  "_id":"4",

                  "_version":1,

                  "status":201

                  }

              }  

    }

    检查命令:

    GET /library

    GET /library/books/_mget

    {

        "ids":["1","2","3","4","5"]

    ------------------------------------------------------------------------------

    3、还可以delete、update,但delete没有request body

    ------------------------------------------------------------------------------

    4、批量处理文档的大小最佳值

         需要验证得知

         可以借助插件监控的仪表数据判断

  • 相关阅读:
    WinForm被遮挡的控件解决方案
    IC卡资料
    水晶报表2008部署
    打造最强的VC6
    SqlServer Case
    using namespace std
    非接触式IC智能(射频)卡
    删除VS2005插件

    SQLServer2005数据库自动备份
  • 原文地址:https://www.cnblogs.com/lexiaofei/p/6650002.html
Copyright © 2011-2022 走看看