1
1
[[search-shards]]
2
2
=== Search Shards API
3
3
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
+
4
23
The search shards api returns the indices and shards that a search request would
5
24
be executed against. This can give useful feedback for working out issues or
6
25
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
+
8
28
9
- The `index` may be a single value, or comma-separated.
29
+ [[search-shards-api-path-params]]
30
+ ==== {api-path-parms-title}
10
31
11
- [float]
12
- ==== Usage
32
+ include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
13
33
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}
15
57
16
58
[source,js]
17
59
--------------------------------------------------
@@ -20,7 +62,7 @@ GET /twitter/_search_shards
20
62
// CONSOLE
21
63
// TEST[s/^/PUT twitter\n{"settings":{"index.number_of_shards":5}}\n/]
22
64
23
- This will yield the following result:
65
+ The API returns the following result:
24
66
25
67
[source,js]
26
68
--------------------------------------------------
@@ -96,7 +138,7 @@ This will yield the following result:
96
138
// TESTRESPONSE[s/bU_KLGJISbW0RejwnwDPKw/$body.shards.3.0.allocation_id.id/]
97
139
// TESTRESPONSE[s/DMs7_giNSwmdqVukF7UydA/$body.shards.4.0.allocation_id.id/]
98
140
99
- And specifying the same request, this time with a routing value:
141
+ Specifying the same request, this time with a routing value:
100
142
101
143
[source,js]
102
144
--------------------------------------------------
@@ -105,7 +147,7 @@ GET /twitter/_search_shards?routing=foo,bar
105
147
// CONSOLE
106
148
// TEST[s/^/PUT twitter\n{"settings":{"index.number_of_shards":5}}\n/]
107
149
108
- This will yield the following result:
150
+ The API returns the following result:
109
151
110
152
[source,js]
111
153
--------------------------------------------------
@@ -145,24 +187,5 @@ This will yield the following result:
145
187
// TESTRESPONSE[s/0TvkCyF7TAmM1wHP4a42-A/$body.shards.1.0.allocation_id.id/]
146
188
// TESTRESPONSE[s/fMju3hd1QHWmWrIgFnI4Ww/$body.shards.0.0.allocation_id.id/]
147
189
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