检索多个文档
如果需要在ElasticSearch中通过一个请求检索多个文档,可使用muli-get或者mget API进行检索。
格式如下:
POST /_mget
{
"docs": [
{
"_id": 2,
"_index": "website",
"_type": "blog"
},
{
"_id": 1,
"_index": "website",
"_source": "views",
"_type": "pageviews"
}
]
}
mget参数是一个docs数据,每一个节点定义一个文档。添加_source参数可设置只检索的字段。