[[reference-reindex]]
== client.reindex

////////
===========================================================================================================================
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
||        ██████╗ ███████╗ █████╗ ██████╗ ███╗   ███╗███████╗                                                            ||
||        ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝                                                            ||
||        ██████╔╝█████╗  ███████║██║  ██║██╔████╔██║█████╗                                                              ||
||        ██╔══██╗██╔══╝  ██╔══██║██║  ██║██║╚██╔╝██║██╔══╝                                                              ||
||        ██║  ██║███████╗██║  ██║██████╔╝██║ ╚═╝ ██║███████╗                                                            ||
||        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚══════╝                                                            ||
||                                                                                                                       ||
||                                                                                                                       ||
||    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>                                                                    ||
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
===========================================================================================================================
////////
++++
<style>
.lang-ts a.xref {
  text-decoration: underline !important;
}
</style>
++++


[discrete]
[[client.reindex]]
== `client.reindex()`

Reindex documents. Copies documents from a source to a destination. The source can be any existing index, alias, or data stream. The destination must differ from the source. For example, you cannot reindex a data stream into itself.

{ref}/docs-reindex.html[{es} documentation]
[discrete]
=== Function signature

[source,ts]
----
(request: ReindexRequest, options?: TransportRequestOptions) => Promise<ReindexResponse>
----

[discrete]
=== Request

[source,ts,subs=+macros]
----
interface ReindexRequest extends <<RequestBase>> {
  refresh?: boolean
  requests_per_second?: <<float>>
  scroll?: <<Duration>>
  slices?: <<Slices>>
  timeout?: <<Duration>>
  wait_for_active_shards?: <<WaitForActiveShards>>
  wait_for_completion?: boolean
  require_alias?: boolean
  conflicts?: <<Conflicts>>
  dest: <<ReindexDestination>>
  max_docs?: <<long>>
  script?: <<Script>> | string
  size?: <<long>>
  source: <<ReindexSource>>
}

----


[discrete]
=== Response

[source,ts,subs=+macros]
----
interface ReindexResponse {
  batches?: <<long>>
  created?: <<long>>
  deleted?: <<long>>
  failures?: <<BulkIndexByScrollFailure>>[]
  noops?: <<long>>
  retries?: <<Retries>>
  requests_per_second?: <<float>>
  slice_id?: <<integer>>
  task?: <<TaskId>>
  throttled_millis?: <<EpochTime>><<<UnitMillis>>>
  throttled_until_millis?: <<EpochTime>><<<UnitMillis>>>
  timed_out?: boolean
  took?: <<DurationValue>><<<UnitMillis>>>
  total?: <<long>>
  updated?: <<long>>
  version_conflicts?: <<long>>
}

----


