7 batch query mget, bulk edit bulk

Note: When performing a plurality of data queries, additions and deletions, be sure to use mget, bulk, improve performance, reduce network traffic
 
mget
 
Review: Query a single document
GET /beauties/my/2
 
mget query multiple documents: different index, different type, different id
GET /_mget
{
    "docs":[
        {
            "_index":"beauties",
            "_type":"my",
            "_id":1
        },
        {
            "_index":"beauties",
            "_type":"my",
            "_id":2
        }
    ]
}
 
Query multiple documents: the same index, a different type, different id
GET /beauties/_mget
{
    "docs":[
        {
            "_type":"my",
            "_id":1
        },
        {
            "_type":"my",
            "_id":2
        }
    ]
}
 
Query id with different index, the same type,
GET /beauties/my/_mget
{
    "ids":[1,2,3]
}
 
 
bulk
Each string can not wrap json, json different strings must wrap
 
POST /_bulk
{ "Create": { "_ index": "beauties", "_ type": "my", "_ id": 7}} // this line and the next line is to create a document
{"name":"mina","age":20,"chest":"28C"}
{ "Index": { "_ index": "test_index_new", "_ type": "test_type_new", "_ id": 1}} // this line and the next line is to create documents
{"test_type_new":"111TYPE"}
{ "Update": { "_ index": "beauties", "_ type": "my", "_ id": 7}} // this line and the next line are partial update
{"doc":{"chest":"29C"}}
{"delete":{"_index":"beauties","_type":"my","_id":"1"}} //删除
 
Note: bulk All operations will into memory, therefore, the number of bars in the bulk is not better. ES eat too much but leads to memory performance. Generally from 5000-10000 strip (request size 5M-15M) to start the test to find the most suitable for the current cluster configuration of bulk size.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Guess you like

Origin www.cnblogs.com/cc299/p/11032812.html