06_Elasticsearch 批量获取mget

06_Elasticsearch 批量获取mget

现在有:

http://192.168.32.81:9200/bank/bank_account/1

http://192.168.32.81:9200/bank/bank_account/2

http://192.168.32.81:9200/bank/bank_account/3

http://192.168.32.81:9200/bank/bank_account/4

http://192.168.32.81:9200/_mget/
                             POST
{
  "docs":[
     {
      "_index":"bank",
      "_type":"bank_account",
      "_id":1
},

     {
      "_index":"bank",
      "_type":"bank_account",
      "_id":2
},
     {
      "_index":"bank",
      "_type":"bank_account",
      "_id":3
  } 
 ]
}


返回:
{

    "docs": [
        {
            "_index": "bank",
            "_type": "bank_account",
            "_id": "1",
            "_version": 1,
            "found": true,
            "_source": {
                "title": "Elasticsearch:The scan",
                "name": {
                    "first": "aaa",
                    "last": "bbb"
                },
                "publish_date": "2016-09-06",
                "price": "49"
            }
        }
        ,
        {
            "_index": "bank",
            "_type": "bank_account",
            "_id": "2",
            "_version": 1,
            "found": true,
            "_source": {
                "title": "Elasticsearch:The scan",
                "name": {
                    "first": "aaa",
                    "last": "bbb"
                },
                "publish_date": "2016-09-06",
                "price": "59"
            }
        }
        ,
        {
            "_index": "bank",
            "_type": "bank_account",
            "_id": "3",
            "_version": 1,
            "found": true,
            "_source": {
                "title": "Elasticsearch:The scan",
                "name": {
                    "first": "aaa",
                    "last": "bbb"
                },
                "publish_date": "2016-09-06",
                "price": "69"
            }
        }
    ]

}


获取某个字段:
{
  "docs":[
     {
      "_index":"bank",
      "_type":"bank_account",
      "_id":1,
      "_source":"price"
},

     {
      "_index":"bank",
      "_type":"bank_account",
      "_id":2,
       "_source":"price"
},
     {
      "_index":"bank",
      "_type":"bank_account",
      "_id":3,
"_source":"price"
  } ,
   {
      "_index":"bank",
      "_type":"bank_account",
      "_id":4,
"_source":"price"
  } 
 ]
}

阅读更多
换一批

没有更多推荐了,返回首页