Elasticsearch multi-index get request 不起作用



如何在多个索引上使用 GET api?

我尝试了以下方法,但不断出现索引丢失异常。

http://localhost:9200/index1,index2/_all/AUy25vKhcC3G2n2ukra3

输出:

{
  "error" : "IndexMissingException[[index1,index2] missing]",
  "status" : 404
}

请帮忙

使用多获取 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"
         }
      }
   ]
}

最新更新