批量获取文档

使用es提供的Multi Get API:

使用Multi Get API 可以通过索引名、类型名、文档id一次得到一个文档集合,文档可以来自同一个索引库,也可以来自不同索引库

在Kibana中:

GET /_mget
{
  "docs":[
    {
      "_index":"lib",
      "_type":"user",
      "_id":1
    },
    {
       "_index": "lib",
       "_type": "user",
       "_id": 2
   }
  ]
}

可以指定具体的字段:

GET /_mget
{
  "docs":[
    {
      "_index":"lib",
      "_type":"user",
      "_id":1,
      "_source":"interests"
    },
       {
      "_index":"lib",
      "_type":"user",
      "_id":2,
      "_source":["age","interests"]
    }
  ]
}

转载于:https://www.jianshu.com/p/d5b33ef4f73e

猜你喜欢

转载自blog.csdn.net/weixin_33795093/article/details/91222819