es mget批量查询

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mn_kw/article/details/82663030

批量查询的好处
就是一条一条的查询,比如说要查询100条数据,那么就要发送100次网络请求,这个开销还是很大的,如果进行批量查询的话,
查询100条数据,就只要发送1次网络请求,网络请求性能开销缩减100倍

2. meget的语法
GET /_mget
{
    "docs":[
        {
            "_index":"test_index",
            "_type":"test_type",
            "_id":1
        },
        {
            "_index":"test_index2",
            "_type":"test_type2",
            "_id":2
        }
    ]
}

3. 如果查询的document是一个index下的不同type种的话
GET /test_index/_mget
{
    "docs":[
        {
            "_type":"test_type",
            "_id":1
        },
        {
            "_type":"test_type2",
            "_id":2
        }
    ]
}

4. 如果查询的数据都在同一个index下的同一个type下,最简单了
GET /test_index/test_type/_mget
{
    "ids":[1,2]
}

猜你喜欢

转载自blog.csdn.net/mn_kw/article/details/82663030