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
|
|
|
--------------------------------------------------
|
|
|
|
GET /twitter/_search_shards
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[s/^/PUT twitter\n{"settings":{"index.number_of_shards":5}}\n/]
|
|
|
|
|
|
|
|
|
|
|
|
[[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
|
|
|
|
2019-09-04 05:34:30 -04:00
|
|
|
include::{docdir}/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}
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
|
|
|
+
|
|
|
|
--
|
|
|
|
Defaults to `open`.
|
|
|
|
--
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=preference]
|
|
|
|
|
|
|
|
include::{docdir}/rest-api/common-parms.asciidoc[tag=routing]
|
|
|
|
|
|
|
|
|
|
|
|
[[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
|
|
|
--------------------------------------------------
|
2016-09-14 11:23:25 -04:00
|
|
|
GET /twitter/_search_shards
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
2018-05-14 12:22:35 -04:00
|
|
|
// TEST[s/^/PUT twitter\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" : {
|
|
|
|
"twitter": { }
|
|
|
|
},
|
2014-04-21 21:34:01 -04:00
|
|
|
"shards": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
--------------------------------------------------
|
2017-11-23 03:48:54 -05:00
|
|
|
GET /twitter/_search_shards?routing=foo,bar
|
2014-04-21 21:34:01 -04:00
|
|
|
--------------------------------------------------
|
2018-05-14 12:22:35 -04:00
|
|
|
// TEST[s/^/PUT twitter\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" : {
|
|
|
|
"twitter": { }
|
|
|
|
},
|
2014-04-21 21:34:01 -04:00
|
|
|
"shards": [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"index": "twitter",
|
|
|
|
"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
|
|
|
|
2020-02-07 14:03:56 -05:00
|
|
|
Because of the specified routing values,
|
|
|
|
the search is only executed against two of the shards.
|