Skip to content

Commit ded2791

Browse files
szabostevejrodewig
andauthored
[DOCS] Reformats search shards API (#46240)
* [DOCS] Reformats search shards API Co-Authored-By: James Rodewig <[email protected]>
1 parent fc2f4f1 commit ded2791

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

docs/reference/search/search-shards.asciidoc

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,59 @@
11
[[search-shards]]
22
=== Search Shards API
33

4+
Returns the indices and shards that a search request would be executed against.
5+
6+
[source,js]
7+
--------------------------------------------------
8+
GET /twitter/_search_shards
9+
--------------------------------------------------
10+
// CONSOLE
11+
// TEST[s/^/PUT twitter\n{"settings":{"index.number_of_shards":5}}\n/]
12+
13+
14+
[[search-shards-api-request]]
15+
==== {api-request-title}
16+
17+
`GET /<index>/_search_shards`
18+
19+
20+
[[search-shards-api-desc]]
21+
==== {api-description-title}
22+
423
The search shards api returns the indices and shards that a search request would
524
be executed against. This can give useful feedback for working out issues or
625
planning optimizations with routing and shard preferences. When filtered aliases
7-
are used, the filter is returned as part of the `indices` section [5.1.0] Added in 5.1.0.
26+
are used, the filter is returned as part of the `indices` section.
27+
828

9-
The `index` may be a single value, or comma-separated.
29+
[[search-shards-api-path-params]]
30+
==== {api-path-parms-title}
1031

11-
[float]
12-
==== Usage
32+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
1333

14-
Full example:
34+
35+
[[search-shards-api-query-params]]
36+
==== {api-query-parms-title}
37+
38+
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
39+
40+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
41+
+
42+
--
43+
Defaults to `open`.
44+
--
45+
46+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
47+
48+
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
49+
50+
include::{docdir}/rest-api/common-parms.asciidoc[tag=preference]
51+
52+
include::{docdir}/rest-api/common-parms.asciidoc[tag=routing]
53+
54+
55+
[[search-shards-api-example]]
56+
==== {api-examples-title}
1557

1658
[source,js]
1759
--------------------------------------------------
@@ -20,7 +62,7 @@ GET /twitter/_search_shards
2062
// CONSOLE
2163
// TEST[s/^/PUT twitter\n{"settings":{"index.number_of_shards":5}}\n/]
2264

23-
This will yield the following result:
65+
The API returns the following result:
2466

2567
[source,js]
2668
--------------------------------------------------
@@ -96,7 +138,7 @@ This will yield the following result:
96138
// TESTRESPONSE[s/bU_KLGJISbW0RejwnwDPKw/$body.shards.3.0.allocation_id.id/]
97139
// TESTRESPONSE[s/DMs7_giNSwmdqVukF7UydA/$body.shards.4.0.allocation_id.id/]
98140

99-
And specifying the same request, this time with a routing value:
141+
Specifying the same request, this time with a routing value:
100142

101143
[source,js]
102144
--------------------------------------------------
@@ -105,7 +147,7 @@ GET /twitter/_search_shards?routing=foo,bar
105147
// CONSOLE
106148
// TEST[s/^/PUT twitter\n{"settings":{"index.number_of_shards":5}}\n/]
107149

108-
This will yield the following result:
150+
The API returns the following result:
109151

110152
[source,js]
111153
--------------------------------------------------
@@ -145,24 +187,5 @@ This will yield the following result:
145187
// TESTRESPONSE[s/0TvkCyF7TAmM1wHP4a42-A/$body.shards.1.0.allocation_id.id/]
146188
// TESTRESPONSE[s/fMju3hd1QHWmWrIgFnI4Ww/$body.shards.0.0.allocation_id.id/]
147189

148-
This time the search will only be executed against two of the shards, because
149-
routing values have been specified.
150-
151-
[float]
152-
==== All parameters:
153-
154-
[horizontal]
155-
`routing`::
156-
A comma-separated list of routing values to take into account when
157-
determining which shards a request would be executed against.
158-
159-
`preference`::
160-
Controls a `preference` of which shard replicas to execute the search
161-
request on. By default, the operation is randomized between the shard
162-
replicas. See the link:search-request-body.html#request-body-search-preference[preference]
163-
documentation for a list of all acceptable values.
164-
165-
`local`::
166-
A boolean value whether to read the cluster state locally in order to
167-
determine where shards are allocated instead of using the Master node's
168-
cluster state.
190+
The search will only be executed against two of the shards, because outing
191+
values have been specified.

0 commit comments

Comments
 (0)