- Elasticsearch 7.0 Cookbook(Fourth Edition)
- Alberto Paro
- 135字
- 2021-06-24 14:52:32
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:
- 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.
- 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.