ElasticSearch学习

文章40 |   阅读 18921 |   点赞0

来源:https://blog.csdn.net/ywl470812087/category_9621251.html

Multi GET  API

x33g5p2x  于2021-12-19 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(342)

Multi GET  API介绍

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

#返回值 

{
  "docs" : [
    {
      "_index" : "lib",
      "_type" : "user",
      "_id" : "1",
      "_version" : 1,
      "_seq_no" : 7,
      "_primary_term" : 1,
      "found" : true,
      "_source" : {
        "first_name" : "Jane",
        "last_name" : "Smith",
        "age" : 36,
        "about" : "I like to collect rock albums",
        "interests" : [
          "music"
        ]
      }
    },
    {
      "_index" : "lib",
      "_type" : "user",
      "_id" : "2",
      "_version" : 1,
      "_seq_no" : 3,
      "_primary_term" : 1,
      "found" : true,
      "_source" : {
        "first_name" : "Jane",
        "last_name" : "tom",
        "age" : 38,
        "about" : "I like to collect rock albums",
        "interests" : [
          "music"
        ]
      }
    }
  ]
}

更简单的:

GET /lib/user/_mget
{
  "ids":["1","2","3"]
}

返回结果: 

{
  "docs" : [
    {
      "_index" : "lib",
      "_type" : "user",
      "_id" : "1",
      "_version" : 1,
      "_seq_no" : 7,
      "_primary_term" : 1,
      "found" : true,
      "_source" : {
        "first_name" : "Jane",
        "last_name" : "Smith",
        "age" : 36,
        "about" : "I like to collect rock albums",
        "interests" : [
          "music"
        ]
      }
    },
    {
      "_index" : "lib",
      "_type" : "user",
      "_id" : "2",
      "_version" : 1,
      "_seq_no" : 3,
      "_primary_term" : 1,
      "found" : true,
      "_source" : {
        "first_name" : "Jane",
        "last_name" : "tom",
        "age" : 38,
        "about" : "I like to collect rock albums",
        "interests" : [
          "music"
        ]
      }
    },
    {
      "_index" : "lib",
      "_type" : "user",
      "_id" : "3",
      "found" : false
    }
  ]
}

相关文章