How to do it...

The multi GET REST URLs are as follows:

http://<server</_mget
http://<server>/<index_name>/_mget

To execute a multi GET action, we will perform the following steps:

  1. The method is POST with a body that contains a list of document IDs and the index or type if they are missing. As an example, using the first URL, we need to provide the index, type, and ID:
POST /_mget
{
"docs": [
{
"_index": "myindex",
"_id": "2qLrAfPVQvCRMe7Ku8r0Tw"
},
{
"_index": "myindex",
"_id": "2"
}
]
}

This kind of call allows us to fetch documents in several different indices and types.

  1. If the index and the type are fixed, a call should also be in the following form:
GET /myindex/_mget
{
"ids" : ["1", "2"]
}

The multi GET result is an array of documents.