Clone index

The clone index API operation clones all data in an existing read-only index into a new index. The new index cannot already exist.

Example

  1. PUT /sample-index1/_clone/cloned-index1
  2. {
  3. "settings": {
  4. "index": {
  5. "number_of_shards": 2,
  6. "number_of_replicas": 1
  7. }
  8. },
  9. "aliases": {
  10. "sample-alias1": {}
  11. }
  12. }

copy

Path and HTTP methods

  1. POST /<source-index>/_clone/<target-index>
  2. PUT /<source-index>/_clone/<target-index>

Index naming restrictions

OpenSearch indexes have the following naming restrictions:

  • All letters must be lowercase.
  • Index names can’t begin with underscores (_) or hyphens (-).
  • Index names can’t contain spaces, commas, or the following characters:

    :, ", *, +, /, \, |, ?, #, >, or <

URL parameters

Your request must include the source and target indexes. All other clone index parameters are optional.

ParameterTypeDescription
<source-index>StringThe source index to clone.
<target-index>StringThe index to create and add cloned data to.
wait_for_active_shardsStringThe number of active shards that must be available before OpenSearch processes the request. Default is 1 (only the primary shard). Set to all or a positive integer. Values greater than 1 require replicas. For example, if you specify a value of 3, the index must have two replicas distributed across two additional nodes for the operation to succeed.
master_timeoutTimeHow long to wait for a connection to the master node. Default is 30s.
timeoutTimeHow long to wait for the request to return. Default is 30s.

Request body

The clone index API operation creates a new target index, so you can specify any index settings and aliases to apply to the target index.

Response

  1. {
  2. "acknowledged": true,
  3. "shards_acknowledged": true,
  4. "index": "cloned-index1"
  5. }