zoukankan      html  css  js  c++  java
  • 7 批量查询mget、批量修改bulk

    注意:当执行多条数据查询、增删改时,一定要用mget、bulk,提升性能,减少网络传输
     
    mget
     
    回顾:查询单个文档
    GET /beauties/my/2
     
    mget 查询多个文档: 不同 index、不同type、不同id
    GET /_mget
    {
        "docs":[
            {
                "_index":"beauties",
                "_type":"my",
                "_id":1
            },
            {
                "_index":"beauties",
                "_type":"my",
                "_id":2
            }
        ]
    }
     
    查询多个文档: 同 index、不同type、不同id
    GET /beauties/_mget
    {
        "docs":[
            {
                "_type":"my",
                "_id":1
            },
            {
                "_type":"my",
                "_id":2
            }
        ]
    }
     
    查询 同 index、同type、不同id
    GET /beauties/my/_mget
    {
        "ids":[1,2,3]
    }
     
     
    bulk
    每个json串都不能换行,不同json串之间,必须换行
     
    POST /_bulk
    {"create":{"_index":"beauties","_type":"my","_id":7}}   //这行和下一行,是创建一个文档
    {"name":"mina","age":20,"chest":"28C"}
    {"index":{"_index":"test_index_new","_type":"test_type_new","_id":1}} //这行 和下一行 是创建文档
    {"test_type_new":"111TYPE"}
    {"update":{"_index":"beauties","_type":"my","_id":7}} //这行 和下一行是 部分更新
    {"doc":{"chest":"29C"}}
    {"delete":{"_index":"beauties","_type":"my","_id":"1"}} //删除
     
    注意:bulk会把所有操作都放到内存中,因此,bulk内的条数不是越多越好。太多反而吃内存导致ES性能下降。一般从5000-10000条(请求大小在5M-15M)开始测试,找到一个最适合当前集群配置的bulk大小。
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    [LeetCode] Implement Stack using Queues
    [LeetCode] String Compression
    [国嵌攻略][060][LCD工作原理解析]
    [国嵌攻略][059][2440-DMA程序设计]
    [国嵌攻略][057][串口控制台建立]
    [国嵌攻略][056][串口驱动程序设计]
    [国嵌攻略][054][NandFlash驱动设计_写]
    [问题笔记][指针相加翻译成汇编右移2位]
    [国嵌攻略][053][6410和210按键中断编程]
    [国嵌攻略][050][2440按键中断编程]
  • 原文地址:https://www.cnblogs.com/cc299/p/11032812.html
Copyright © 2011-2022 走看看