The msearch
API executes several searches with a single API request.
Format: #
GET /<target>/_msearch
header\n
body\n
header\n
body\n
1
2
3
4
5
2
3
4
5
Example: #
GET _msearch
{ "index": "index-1" }
{ "query": { "match_all": {} }, "from" : 0, "size" : 2 }
{ "index": "index-2" }
{ "query": { "match_all": {} }, "from" : 0, "size" : 2 }
1
2
3
4
5
2
3
4
5
{
"responses": [
{
...,
hits: {
"total": 2,
...,
"hits": [
{
"_index" : "index-1",
...,
"_source": {
...
}
},
{
"_index" : "index-1",
...,
"_source": {
...
}
}
]
}
},
{
...,
hits: {
"total": 2,
...,
"hits": [
{
"_index" : "index-2",
...,
"_source": {
...
}
},
{
"_index" : "index-2",
...,
"_source": {
...
}
}
]
}
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
The response returns a responses
array, which includes the search response and status code for each search request matching its order in the original multi search request. If there was a complete failure for that specific search request, an object with error
message and corresponding status code will be returned in place of the actual search response.
Refs: #
- https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-multi-search.html
Comment