2014-04-21 21:34:01 -04:00
|
|
|
[[search-shards]]
|
2019-07-19 14:35:36 -04:00
|
|
|
=== Search Shards API
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
Returns the indices and shards that a search request would be executed against.
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2019-09-04 05:34:30 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
GET /my-index-000001/_search_shards
|
2019-09-04 05:34:30 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
// TEST[s/^/PUT my-index-000001\n{"settings":{"index.number_of_shards":5}}\n/]
|
2019-09-04 05:34:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[search-shards-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
|
|
|
`GET /<index>/_search_shards`
|
|
|
|
|
|
|
|
|
|
|
|
[[search-shards-api-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
2014-04-21 21:34:01 -04:00
|
|
|
The search shards api returns the indices and shards that a search request would
|
|
|
|
be executed against. This can give useful feedback for working out issues or
|
2016-11-22 17:00:25 -05:00
|
|
|
planning optimizations with routing and shard preferences. When filtered aliases
|
2019-09-04 05:34:30 -04:00
|
|
|
are used, the filter is returned as part of the `indices` section.
|
|
|
|
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
[[search-shards-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
|
|
|
|
[[search-shards-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-09-04 05:34:30 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-09-04 05:34:30 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
Defaults to `open`.
|
|
|
|
--
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-09-04 05:34:30 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
|
2019-09-04 05:34:30 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=preference]
|
2019-09-04 05:34:30 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=routing]
|
2019-09-04 05:34:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[search-shards-api-example]]
|
|
|
|
==== {api-examples-title}
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
GET /my-index-000001/_search_shards
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
// TEST[s/^/PUT my-index-000001\n{"settings":{"index.number_of_shards":5}}\n/]
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
The API returns the following result:
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2016-09-14 11:23:25 -04:00
|
|
|
"nodes": ...,
|
2016-11-22 17:00:25 -05:00
|
|
|
"indices" : {
|
2020-08-04 14:16:38 -04:00
|
|
|
"my-index-000001": { }
|
2016-11-22 17:00:25 -05:00
|
|
|
},
|
2014-04-21 21:34:01 -04:00
|
|
|
"shards": [
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2016-09-14 11:23:25 -04:00
|
|
|
"shard": 0,
|
|
|
|
"state": "STARTED",
|
|
|
|
"allocation_id": {"id":"0TvkCyF7TAmM1wHP4a42-A"},
|
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2016-09-14 11:23:25 -04:00
|
|
|
"shard": 1,
|
|
|
|
"state": "STARTED",
|
|
|
|
"allocation_id": {"id":"fMju3hd1QHWmWrIgFnI4Ww"},
|
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2016-09-14 11:23:25 -04:00
|
|
|
"shard": 2,
|
|
|
|
"state": "STARTED",
|
|
|
|
"allocation_id": {"id":"Nwl0wbMBTHCWjEEbGYGapg"},
|
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2016-09-14 11:23:25 -04:00
|
|
|
"shard": 3,
|
|
|
|
"state": "STARTED",
|
|
|
|
"allocation_id": {"id":"bU_KLGJISbW0RejwnwDPKw"},
|
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2016-09-14 11:23:25 -04:00
|
|
|
"shard": 4,
|
|
|
|
"state": "STARTED",
|
|
|
|
"allocation_id": {"id":"DMs7_giNSwmdqVukF7UydA"},
|
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-09-14 11:23:25 -04:00
|
|
|
// TESTRESPONSE[s/"nodes": ...,/"nodes": $body.nodes,/]
|
|
|
|
// TESTRESPONSE[s/JklnKbD7Tyqi9TP3_Q_tBg/$body.shards.0.0.node/]
|
|
|
|
// TESTRESPONSE[s/0TvkCyF7TAmM1wHP4a42-A/$body.shards.0.0.allocation_id.id/]
|
|
|
|
// TESTRESPONSE[s/fMju3hd1QHWmWrIgFnI4Ww/$body.shards.1.0.allocation_id.id/]
|
|
|
|
// TESTRESPONSE[s/Nwl0wbMBTHCWjEEbGYGapg/$body.shards.2.0.allocation_id.id/]
|
|
|
|
// TESTRESPONSE[s/bU_KLGJISbW0RejwnwDPKw/$body.shards.3.0.allocation_id.id/]
|
|
|
|
// TESTRESPONSE[s/DMs7_giNSwmdqVukF7UydA/$body.shards.4.0.allocation_id.id/]
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
Specifying the same request, this time with a routing value:
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
GET /my-index-000001/_search_shards?routing=foo,bar
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
2020-08-04 14:16:38 -04:00
|
|
|
// TEST[s/^/PUT my-index-000001\n{"settings":{"index.number_of_shards":5}}\n/]
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
The API returns the following result:
|
2014-04-21 21:34:01 -04:00
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2016-09-14 11:23:25 -04:00
|
|
|
"nodes": ...,
|
2016-11-22 17:00:25 -05:00
|
|
|
"indices" : {
|
2020-08-04 14:16:38 -04:00
|
|
|
"my-index-000001": { }
|
2016-11-22 17:00:25 -05:00
|
|
|
},
|
2014-04-21 21:34:01 -04:00
|
|
|
"shards": [
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2017-11-23 03:48:54 -05:00
|
|
|
"shard": 2,
|
2016-09-14 11:23:25 -04:00
|
|
|
"state": "STARTED",
|
2017-11-23 03:48:54 -05:00
|
|
|
"allocation_id": {"id":"fMju3hd1QHWmWrIgFnI4Ww"},
|
2016-09-14 11:23:25 -04:00
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
2020-08-04 14:16:38 -04:00
|
|
|
"index": "my-index-000001",
|
2014-04-21 21:34:01 -04:00
|
|
|
"node": "JklnKbD7Tyqi9TP3_Q_tBg",
|
|
|
|
"primary": true,
|
2017-11-23 03:48:54 -05:00
|
|
|
"shard": 3,
|
2016-09-14 11:23:25 -04:00
|
|
|
"state": "STARTED",
|
2017-11-23 03:48:54 -05:00
|
|
|
"allocation_id": {"id":"0TvkCyF7TAmM1wHP4a42-A"},
|
2016-09-14 11:23:25 -04:00
|
|
|
"relocating_node": null
|
2014-04-21 21:34:01 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2016-09-14 11:23:25 -04:00
|
|
|
// TESTRESPONSE[s/"nodes": ...,/"nodes": $body.nodes,/]
|
2017-11-23 03:48:54 -05:00
|
|
|
// TESTRESPONSE[s/JklnKbD7Tyqi9TP3_Q_tBg/$body.shards.1.0.node/]
|
|
|
|
// TESTRESPONSE[s/0TvkCyF7TAmM1wHP4a42-A/$body.shards.1.0.allocation_id.id/]
|
|
|
|
// TESTRESPONSE[s/fMju3hd1QHWmWrIgFnI4Ww/$body.shards.0.0.allocation_id.id/]
|
2014-04-21 21:34:01 -04:00
|
|
|
|
Deprecate REST access to System Indices (#63274) (Original #60945)
This PR adds deprecation warnings when accessing System Indices via the REST layer. At this time, these warnings are only enabled for Snapshot builds by default, to allow projects external to Elasticsearch additional time to adjust their access patterns.
Deprecation warnings will be triggered by all REST requests which access registered System Indices, except for purpose-specific APIs which access System Indices as an implementation detail a few specific APIs which will continue to allow access to system indices by default:
- `GET _cluster/health`
- `GET {index}/_recovery`
- `GET _cluster/allocation/explain`
- `GET _cluster/state`
- `POST _cluster/reroute`
- `GET {index}/_stats`
- `GET {index}/_segments`
- `GET {index}/_shard_stores`
- `GET _cat/[indices,aliases,health,recovery,shards,segments]`
Deprecation warnings for accessing system indices take the form:
```
this request accesses system indices: [.some_system_index], but in a future major version, direct access to system indices will be prevented by default
```
2020-10-06 15:41:40 -04:00
|
|
|
Because of the specified routing values,
|
2020-02-07 14:03:56 -05:00
|
|
|
the search is only executed against two of the shards.
|