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、批量处理文档的大小最佳值

         需要验证得知

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

  • 相关阅读:
    JAAS configuration for Kafka clients
    kafka集群安全化之启用kerberos与acl
    配置两个不同kerberos认证中心的集群间的互信
    hbase-indexer官网wiki
    KSQL: Streaming SQL for Apache Kafka
    Introducing KSQL: Streaming SQL for Apache Kafka
    Sqoop import导入表时报错java.lang.ClassNotFoundException: org.json.JSONObject
    重磅开源 KSQL:用于 Apache Kafka 的流数据 SQL 引擎 2017.8.29
    sqoop与hbase导入导出数据
    用sqoop将mysql的数据导入到hive表中
  • 原文地址:https://www.cnblogs.com/lexiaofei/p/6650002.html
Copyright © 2011-2022 走看看