Skip to content

Commit 98bcf06

Browse files
committed
[DOCS] Correct multi search API docs (#52523)
* Adds an example request to the top of the page. * Relocates several parameters erroneously listed under "Request body" to the appropriate "Query parameters" section. * Updates the "Request body" section to better document the NDJSON structure of msearch requests.
1 parent c03f51f commit 98bcf06

File tree

1 file changed

+193
-38
lines changed

1 file changed

+193
-38
lines changed

docs/reference/search/multi-search.asciidoc

Lines changed: 193 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33

44
Executes several searches with a single API request.
55

6+
[source,console]
7+
--------------------------------------------------
8+
GET twitter/_msearch
9+
{ }
10+
{"query" : {"match" : { "message": "this is a test"}}}
11+
{"index": "twitter2"}
12+
{"query" : {"match_all" : {}}}
13+
--------------------------------------------------
14+
// TEST[setup:twitter]
15+
616
[[search-multi-search-api-request]]
717
==== {api-request-title}
818

@@ -12,11 +22,11 @@ Executes several searches with a single API request.
1222
[[search-multi-search-api-desc]]
1323
==== {api-description-title}
1424

15-
The multi search AP executes several searches from a single API request.
25+
The multi search API executes several searches from a single API request.
1626
The format of the request is similar to the bulk API format and makes use
17-
of the newline delimited JSON (NDJSON) format. The structure is as follows (the
18-
structure is specifically optimized to reduce parsing if a specific search ends
19-
up redirected to another node):
27+
of the newline delimited JSON (NDJSON) format.
28+
29+
The structure is as follows:
2030

2131
[source,js]
2232
--------------------------------------------------
@@ -27,53 +37,198 @@ body\n
2737
--------------------------------------------------
2838
// NOTCONSOLE
2939

30-
*NOTE*: the final line of data must end with a newline character `\n`. Each newline character
31-
may be preceded by a carriage return `\r`. When sending requests to this endpoint the
32-
`Content-Type` header should be set to `application/x-ndjson`.
40+
This structure is specifically optimized to reduce parsing if a specific search
41+
ends up redirected to another node.
42+
43+
[IMPORTANT]
44+
====
45+
The final line of data must end with a newline character `\n`. Each newline
46+
character may be preceded by a carriage return `\r`. When sending requests to
47+
this endpoint the `Content-Type` header should be set to `application/x-ndjson`.
48+
====
3349

3450
[[search-multi-search-api-path-params]]
3551
==== {api-path-parms-title}
3652

3753
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
54+
+
55+
To search all indices, use `_all` or omit this parameter.
3856

57+
[[search-multi-search-api-query-params]]
58+
==== {api-query-parms-title}
3959

40-
[[search-multi-search-api-request-body]]
41-
==== {api-request-body-title}
60+
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
61+
62+
`ccs_minimize_roundtrips`::
63+
(Optional, boolean)
64+
If `true`, network roundtrips between the coordinating node and remote clusters
65+
are minimized for {ccs} requests. Defaults to `true`. See
66+
<<ccs-network-delays>>.
67+
68+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
69+
+
70+
Defaults to `open`.
71+
72+
`ignore_throttled`::
73+
(Optional, boolean)
74+
If `true`, concrete, expanded or aliased indices are ignored when throttled.
75+
Defaults to `false`.
76+
77+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
4278

43-
`aggregations`::
44-
(Optional, object) Specifies aggregations.
45-
46-
include::{docdir}/rest-api/common-parms.asciidoc[tag=from]
47-
4879
`max_concurrent_searches`::
49-
(Optional, integer) Specifies the maximum number of concurrent searches the
50-
multi search API will execute. This default is based on the number of data
51-
nodes and the default search thread pool size.
52-
80+
(Optional, integer)
81+
Maximum number of concurrent searches the multi search API can execute.
82+
5383
`max_concurrent_shard_requests`::
54-
(Optional, integer) Specifies the maximum number of concurrent shard requests
55-
that each sub search request will execute per node. This parameter should be
56-
used to protect a single request from overloading a cluster (for example a
57-
default request will hit all indices in a cluster which could cause shard
58-
request rejections if the number of shards per node is high). Defaults to `5`.
59-
In certain scenarios parallelism isn't achieved through concurrent request
60-
such that this protection will result in poor performance. For instance in an
61-
environment where only a very low number of concurrent search requests are
62-
expected it might help to increase this value to a higher number.
63-
64-
include::{docdir}/rest-api/common-parms.asciidoc[tag=preference]
84+
+
85+
--
86+
(Optional, integer)
87+
Maximum number of concurrent shard requests that each sub-search request
88+
executes per node. Defaults to `5`.
89+
90+
You can use this parameter to prevent a request from overloading a cluster. For
91+
example, a default request hits all indices in a cluster. This could cause shard
92+
request rejections if the number of shards per node is high.
93+
94+
In certain scenarios, parallelism isn't achieved through concurrent requests. In
95+
those cases, a low value in this parameter could result in poor performance.
96+
For example, in an environment where a very low number of concurrent search
97+
requests are expected, a higher value in this parameter may improve performance.
98+
--
99+
100+
`pre_filter_shard_size`::
101+
(Optional, integer)
102+
Defines a threshold that enforces a pre-filter roundtrip to prefilter search
103+
shards based on query rewriting if the number of shards the search request
104+
expands to exceeds the threshold. This filter roundtrip can limit the number of
105+
shards significantly if for instance a shard can not match any documents based
106+
on it's rewrite method i.e., if date filters are mandatory to match but the
107+
shard bounds and the query are disjoint. Defaults to `128`.
108+
109+
`rest_total_hits_as_int`::
110+
(Optional, boolean)
111+
If `true`, `hits.total` are returned as an integer in the
112+
response. Defaults to `false`, which returns an object.
113+
114+
`routing`::
115+
(Optional, string)
116+
Custom <<mapping-routing-field,routing value>> used to route search operations
117+
to a specific shard.
118+
119+
`search_type`::
120+
+
121+
--
122+
(Optional, string)
123+
Indicates whether global term and document frequencies should be used when
124+
scoring returned documents.
125+
126+
Options are:
127+
128+
`query_then_fetch`::
129+
(default)
130+
Documents are scored using local term and document frequencies for the shard.
131+
This is usually faster but less accurate.
132+
133+
`dfs_query_then_fetch`::
134+
Documents are scored using global term and document frequencies across all
135+
shards. This is usually slower but more accurate.
136+
--
65137

66-
`query`::
67-
(Optional, <<query-dsl,query object>>) Defines the search definition using the
68-
<<query-dsl,Query DSL>>.
69-
70-
include::{docdir}/rest-api/common-parms.asciidoc[tag=routing]
71-
72-
include::{docdir}/rest-api/common-parms.asciidoc[tag=search_type]
138+
`typed_keys`::
139+
(Optional, boolean)
140+
Specifies whether aggregation and suggester names should be prefixed by their
141+
respective types in the response.
73142

74-
`size`::
75-
(Optional, integer) The number of hits to return. Defaults to `10`.
143+
[[search-multi-search-api-request-body]]
144+
==== {api-request-body-title}
76145

146+
The request body contains a newline-delimited list of search `<header>` and
147+
search `<body>` objects.
148+
149+
`<header>`::
150+
+
151+
--
152+
(Required, object)
153+
Contains parameters used to limit or change the subsequent search body request.
154+
155+
This object is required for each search body but can be empty (`{}`) or a blank
156+
line.
157+
--
158+
159+
`allow_no_indices`:::
160+
(Optional, boolean)
161+
If `true`, the request does *not* return an error if a wildcard expression or
162+
`_all` value retrieves only missing or closed indices.
163+
+
164+
This parameter also applies to <<indices-aliases,index aliases>> that point to a
165+
missing or closed index.
166+
167+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
168+
+
169+
Defaults to `open`.
170+
171+
`ignore_unavailable`:::
172+
(Optional, boolean) If `true`, documents from missing or closed indices are not
173+
included in the response. Defaults to `false`.
174+
175+
`index`:::
176+
(Optional, string or array of strings)
177+
Index name or <<indices-aliases,alias>> used to limit the request. Wildcard
178+
expressions are supported. You can specify multiple indices as an array.
179+
180+
`preference`:::
181+
(Optional, string)
182+
Node or shard used to perform the search. Random by default.
183+
184+
`request_cache`:::
185+
(Optional, boolean)
186+
If `true`, the request cache can be used for this search. Defaults to
187+
index-level settings. See <<shard-request-cache>>.
188+
189+
`routing`:::
190+
(Optional, string)
191+
Custom <<mapping-routing-field,routing value>> used to route search operations
192+
to a specific shard.
193+
194+
`search_type`:::
195+
+
196+
--
197+
(Optional, string)
198+
Indicates whether global term and document frequencies should be used when
199+
scoring returned documents.
200+
201+
Options are:
202+
203+
`query_then_fetch`::
204+
(default)
205+
Documents are scored using local term and document frequencies for the shard.
206+
This is usually faster but less accurate.
207+
208+
`dfs_query_then_fetch`::
209+
Documents are scored using global term and document frequencies across all
210+
shards. This is usually slower but more accurate.
211+
--
212+
213+
`<body>`::
214+
(Optional, object)
215+
Contains parameters for a search request:
216+
217+
`aggregations`:::
218+
(Optional, <<_structuring_aggregations,aggregation object>>)
219+
Aggregations you wish to run during the search. See <<search-aggregations>>.
220+
221+
`query`:::
222+
(Optional, <<query-dsl,query DSL object>>) Query you wish to run during the
223+
search. Hits matching this query are returned in the response.
224+
225+
`from`:::
226+
(Optional, integer)
227+
Starting offset for returned hits. Defaults to `0`.
228+
229+
`size`:::
230+
(Optional, integer)
231+
Number of hits to return. Defaults to `10`.
77232

78233
[[search-multi-search-api-response-body]]
79234
==== {api-response-body-title}

0 commit comments

Comments
 (0)