如何在多个索引上使用GET api?
我尝试了以下但是我一直在索引缺少异常。
http://localhost:9200/index1,index2/_all/AUy25vKhcC3G2n2ukra3
输出:
{
"error" : "IndexMissingException[[index1,index2] missing]",
"status" : 404
}
请帮忙
答案 0 :(得分:1)
使用multi-get api
示例:
POST test1/index1/1
{
"name": "jon brick"
}
POST test2/index1/1
{
"name": "sriji"
}
GET _mget
{
"docs" : [
{
"_index": "test1",
"_type":"index1",
"_id" : "1"
},
{
"_index": "test2",
"_type":"index1",
"_id" : "1"
}
]
}
结果是:
{
"docs": [
{
"_index": "test1",
"_type": "index1",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "jon brick"
}
},
{
"_index": "test2",
"_type": "index1",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "sriji"
}
}
]
}