---
type: api
title: Create a follower
description: Create a cross-cluster replication follower index that follows a specific leader index.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ccr-follow
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ccr-follow
products:
  - Elasticsearch
---

# Create a follower

Availability: 6.5+

## Paths

- `PUT` `/{index}/_ccr/follow`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/authentication#bearerauth)

#### Path Parameters

- `index` (string IndexName)
  The name of the follower index.

## Description

Create a cross-cluster replication follower index that follows a specific leader index.
When the API returns, the follower index exists and cross-cluster replication starts replicating operations from the leader index to the follower index.

## Query String Parameters

- `master_timeout` (string Duration · default: 30s)
  Period to wait for a connection to the master node.
- `wait_for_active_shards` (WaitForActiveShards · default: 0)
  Specifies the number of shards to wait on being active before responding. This defaults to waiting on none of the shards to be
active.
A shard must be restored from the leader index before being active. Restoring a follower shard requires transferring all the
remote Lucene segment files to the follower index.
  Values: `all`, `index-setting`

## Request Body

`application/json`

- `data_stream_name` (string) — optional
  If the leader index is part of a data stream, the name to which the local data stream for the followed index should be renamed.
- `leader_index` (string IndexName) — required
  The name of the index in the leader cluster to follow.
- `max_outstanding_read_requests` (number) — optional
  The maximum number of outstanding reads requests from the remote cluster.
- `max_outstanding_write_requests` (number) — optional
  The maximum number of outstanding write requests on the follower.
- `max_read_request_operation_count` (number) — optional
  The maximum number of operations to pull per read from the remote cluster.
- `max_read_request_size` (number | string ByteSize) — optional
  The maximum size in bytes of per read of a batch of operations pulled from the remote cluster.
- `max_retry_delay` (string Duration) — optional
  The maximum time to wait before retrying an operation that failed exceptionally. An exponential backoff strategy is employed when
retrying.
- `max_write_buffer_count` (number) — optional
  The maximum number of operations that can be queued for writing. When this limit is reached, reads from the remote cluster will be
deferred until the number of queued operations goes below the limit.
- `max_write_buffer_size` (number | string ByteSize) — optional
  The maximum total bytes of operations that can be queued for writing. When this limit is reached, reads from the remote cluster will
be deferred until the total bytes of queued operations goes below the limit.
- `max_write_request_operation_count` (number) — optional
  The maximum number of operations per bulk write request executed on the follower.
- `max_write_request_size` (number | string ByteSize) — optional
  The maximum total bytes of operations per bulk write request executed on the follower.
- `read_poll_timeout` (string Duration) — optional
  The maximum time to wait for new operations on the remote cluster when the follower index is synchronized with the leader index.
When the timeout has elapsed, the poll for operations will return to the follower so that it can update some statistics.
Then the follower will immediately attempt to read from the leader again.
- `remote_cluster` (string) — required
  The remote cluster containing the leader index.
- `settings` (IndexSettings) — optional
  Settings to override from the leader index.

## Response

`application/json`

- `follow_index_created` (boolean)
- `follow_index_shards_acked` (boolean)
- `index_following_started` (boolean)
## Code Examples

#### Console

```console
PUT /follower_index/_ccr/follow?wait_for_active_shards=1
{
  "remote_cluster" : "remote_cluster",
  "leader_index" : "leader_index",
  "settings": {
    "index.number_of_replicas": 0
  },
  "max_read_request_operation_count" : 1024,
  "max_outstanding_read_requests" : 16,
  "max_read_request_size" : "1024k",
  "max_write_request_operation_count" : 32768,
  "max_write_request_size" : "16k",
  "max_outstanding_write_requests" : 8,
  "max_write_buffer_count" : 512,
  "max_write_buffer_size" : "512k",
  "max_retry_delay" : "10s",
  "read_poll_timeout" : "30s"
}
```

#### JavaScript

```javascript
const response = await client.ccr.follow({
  index: "follower_index",
  wait_for_active_shards: 1,
  remote_cluster: "remote_cluster",
  leader_index: "leader_index",
  settings: {
    "index.number_of_replicas": 0,
  },
  max_read_request_operation_count: 1024,
  max_outstanding_read_requests: 16,
  max_read_request_size: "1024k",
  max_write_request_operation_count: 32768,
  max_write_request_size: "16k",
  max_outstanding_write_requests: 8,
  max_write_buffer_count: 512,
  max_write_buffer_size: "512k",
  max_retry_delay: "10s",
  read_poll_timeout: "30s",
});
```

#### Python

```python
resp = client.ccr.follow(
    index="follower_index",
    wait_for_active_shards="1",
    remote_cluster="remote_cluster",
    leader_index="leader_index",
    settings={
        "index.number_of_replicas": 0
    },
    max_read_request_operation_count=1024,
    max_outstanding_read_requests=16,
    max_read_request_size="1024k",
    max_write_request_operation_count=32768,
    max_write_request_size="16k",
    max_outstanding_write_requests=8,
    max_write_buffer_count=512,
    max_write_buffer_size="512k",
    max_retry_delay="10s",
    read_poll_timeout="30s",
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/follower_index/_ccr/follow?wait_for_active_shards=1" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "remote_cluster": "remote_cluster",
    "leader_index": "leader_index",
    "settings": {
      "index.number_of_replicas": 0
    },
    "max_read_request_operation_count": 1024,
    "max_outstanding_read_requests": 16,
    "max_read_request_size": "1024k",
    "max_write_request_operation_count": 32768,
    "max_write_request_size": "16k",
    "max_outstanding_write_requests": 8,
    "max_write_buffer_count": 512,
    "max_write_buffer_size": "512k",
    "max_retry_delay": "10s",
    "read_poll_timeout": "30s"
  }'
```

#### Java

```java
client.ccr().follow(f -> f
    .index("follower_index")
    .leaderIndex("leader_index")
    .maxOutstandingReadRequests(16L)
    .maxOutstandingWriteRequests(8)
    .maxReadRequestOperationCount(1024)
    .maxReadRequestSize("1024k")
    .maxRetryDelay(m -> m
        .time("10s")
    )
    .maxWriteBufferCount(512)
    .maxWriteBufferSize("512k")
    .maxWriteRequestOperationCount(32768)
    .maxWriteRequestSize("16k")
    .readPollTimeout(r -> r
        .time("30s")
    )
    .remoteCluster("remote_cluster")
    .settings(s -> s
        .otherSettings("index.number_of_replicas", JsonData.fromJson("0"))
    )
    .waitForActiveShards(w -> w
        .count(1)
    )
);
```

#### PHP

```php
$resp = $client->ccr()->follow([
    "index" => "follower_index",
    "wait_for_active_shards" => "1",
    "body" => [
        "remote_cluster" => "remote_cluster",
        "leader_index" => "leader_index",
        "settings" => [
            "index.number_of_replicas" => 0,
        ],
        "max_read_request_operation_count" => 1024,
        "max_outstanding_read_requests" => 16,
        "max_read_request_size" => "1024k",
        "max_write_request_operation_count" => 32768,
        "max_write_request_size" => "16k",
        "max_outstanding_write_requests" => 8,
        "max_write_buffer_count" => 512,
        "max_write_buffer_size" => "512k",
        "max_retry_delay" => "10s",
        "read_poll_timeout" => "30s",
    ],
]);
```

#### Ruby

```ruby
response = client.ccr.follow(
  index: "follower_index",
  wait_for_active_shards: "1",
  body: {
    "remote_cluster": "remote_cluster",
    "leader_index": "leader_index",
    "settings": {
      "index.number_of_replicas": 0
    },
    "max_read_request_operation_count": 1024,
    "max_outstanding_read_requests": 16,
    "max_read_request_size": "1024k",
    "max_write_request_operation_count": 32768,
    "max_write_request_size": "16k",
    "max_outstanding_write_requests": 8,
    "max_write_buffer_count": 512,
    "max_write_buffer_size": "512k",
    "max_retry_delay": "10s",
    "read_poll_timeout": "30s"
  }
)
```

## Response Examples

#### Create follow index response example1

A successful response from `PUT /follower_index/_ccr/follow?wait_for_active_shards=1`.

```json
{
  "follow_index_created" : true,
  "follow_index_shards_acked" : true,
  "index_following_started" : true
}
```

