[[reference-search_shards]]

////////
===========================================================================================================================
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
||        ██████╗ ███████╗ █████╗ ██████╗ ███╗   ███╗███████╗                                                            ||
||        ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝                                                            ||
||        ██████╔╝█████╗  ███████║██║  ██║██╔████╔██║█████╗                                                              ||
||        ██╔══██╗██╔══╝  ██╔══██║██║  ██║██║╚██╔╝██║██╔══╝                                                              ||
||        ██║  ██║███████╗██║  ██║██████╔╝██║ ╚═╝ ██║███████╗                                                            ||
||        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚══════╝                                                            ||
||                                                                                                                       ||
||                                                                                                                       ||
||    This file is autogenerated, DO NOT send pull requests that changes this file directly.                             ||
||    You should update the script that does the generation, which can be found in:                                      ||
||    https://github.com/elastic/elastic-client-generator-js                                                             ||
||                                                                                                                       ||
||    You can run the script with the following command:                                                                 ||
||       npm run elasticsearch -- --version <version>                                                                    ||
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
===========================================================================================================================
////////

[discrete]
[[client.searchShards]]
=== client.searchShards

Get the search shards. Get the indices and shards that a search request would be run against. This information can be useful for working out issues or planning optimizations with routing and shard preferences. When filtered aliases are used, the filter is returned as part of the indices section.

{ref}/search-shards.html[{es} documentation]

[discrete]
==== Function signature

[source,ts]
----
(SearchShardsRequest, options?): Promise<SearchShardsResponse>
----

[discrete]
==== SearchShardsRequest

[pass]
++++
<pre>
++++
interface SearchShardsRequest extends <<RequestBase>> {
  index?: <<Indices>>
  allow_no_indices?: boolean
  expand_wildcards?: <<ExpandWildcards>>
  ignore_unavailable?: boolean
  local?: boolean
  preference?: string
  routing?: <<Routing>>
}

[pass]
++++
</pre>
++++
[discrete]
==== SearchShardsResponse

[pass]
++++
<pre>
++++
interface SearchShardsResponse {
  nodes: Record<<<NodeId>>, SearchShardsSearchShardsNodeAttributes>
  shards: <<NodeShard>>[][]
  indices: Record<<<IndexName>>, SearchShardsShardStoreIndex>
}

[pass]
++++
</pre>
++++
