# Cross-Cluster Replication (CCR)

class elasticsearch.client.CcrClient

  To use this client, access `client.ccr` from an `Elasticsearch` client. For example:

      from elasticsearch import Elasticsearch

      # Create the client instance
      client = Elasticsearch(...)
      # Use the ccr client
      client.ccr.<method>(...)

  delete_auto_follow_pattern(*, name, error_trace=None, filter_path=None, human=None, pretty=None)

    Delete auto-follow patterns. Delete a collection of cross-cluster replication auto-follow patterns.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-delete-auto-follow-pattern.html

    Parameters:

      - name (str) – The name of the auto follow pattern.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  follow(*, index, error_trace=None, filter_path=None, human=None, leader_index=None, max_outstanding_read_requests=None, max_outstanding_write_requests=None, max_read_request_operation_count=None, max_read_request_size=None, max_retry_delay=None, max_write_buffer_count=None, max_write_buffer_size=None, max_write_request_operation_count=None, max_write_request_size=None, pretty=None, read_poll_timeout=None, remote_cluster=None, wait_for_active_shards=None, body=None)

    Create a follower. 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.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-put-follow.html

    Parameters:

      - index (str) – The name of the follower index

      - leader_index (str | None)

      - max_outstanding_read_requests (int | None)

      - max_outstanding_write_requests (int | None)

      - max_read_request_operation_count (int | None)

      - max_read_request_size (str | None)

      - max_retry_delay (str | Literal[-1] | ~typing.Literal[0] | None)

      - max_write_buffer_count (int | None)

      - max_write_buffer_size (str | None)

      - max_write_request_operation_count (int | None)

      - max_write_request_size (str | None)

      - read_poll_timeout (str | Literal[-1] | ~typing.Literal[0] | None)

      - remote_cluster (str | None)

      - wait_for_active_shards (int | str | Literal['all', 'index-setting'] | None) – Sets the number of shard copies that must be active before returning. Defaults to 0. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  follow_info(*, index, error_trace=None, filter_path=None, human=None, pretty=None)

    Get follower information. Get information about all cross-cluster replication follower indices. For example, the results include follower index names, leader index names, replication options, and whether the follower indices are active or paused.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-get-follow-info.html

    Parameters:

      - index (str | Sequence[str]) – A comma-separated list of index patterns; use _all to perform the operation on all indices

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  follow_stats(*, index, error_trace=None, filter_path=None, human=None, pretty=None)

    Get follower stats. Get cross-cluster replication follower stats. The API returns shard-level stats about the "following tasks" associated with each shard for the specified indices.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-get-follow-stats.html

    Parameters:

      - index (str | Sequence[str]) – A comma-separated list of index patterns; use _all to perform the operation on all indices

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  forget_follower(*, index, error_trace=None, filter_path=None, follower_cluster=None, follower_index=None, follower_index_uuid=None, human=None, leader_remote_cluster=None, pretty=None, body=None)

    Forget a follower. Remove the cross-cluster replication follower retention leases from the leader.

    A following index takes out retention leases on its leader index. These leases are used to increase the likelihood that the shards of the leader index retain the history of operations that the shards of the following index need to run replication. When a follower index is converted to a regular index by the unfollow API (either by directly calling the API or by index lifecycle management tasks), these leases are removed. However, removal of the leases can fail, for example when the remote cluster containing the leader index is unavailable. While the leases will eventually expire on their own, their extended existence can cause the leader index to hold more history than necessary and prevent index lifecycle management from performing some operations on the leader index. This API exists to enable manually removing the leases when the unfollow API is unable to do so.

    NOTE: This API does not stop replication by a following index. If you use this API with a follower index that is still actively following, the following index will add back retention leases on the leader. The only purpose of this API is to handle the case of failure to remove the following retention leases after the unfollow API is invoked.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-post-forget-follower.html

    Parameters:

      - index (str) – the name of the leader index for which specified follower retention leases should be removed

      - follower_cluster (str | None)

      - follower_index (str | None)

      - follower_index_uuid (str | None)

      - leader_remote_cluster (str | None)

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  get_auto_follow_pattern(*, name=None, error_trace=None, filter_path=None, human=None, pretty=None)

    Get auto-follow patterns. Get cross-cluster replication auto-follow patterns.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-get-auto-follow-pattern.html

    Parameters:

      - name (str | None) – Specifies the auto-follow pattern collection that you want to retrieve. If you do not specify a name, the API returns information for all collections.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  pause_auto_follow_pattern(*, name, error_trace=None, filter_path=None, human=None, pretty=None)

    Pause an auto-follow pattern. Pause a cross-cluster replication auto-follow pattern. When the API returns, the auto-follow pattern is inactive. New indices that are created on the remote cluster and match the auto-follow patterns are ignored.

    You can resume auto-following with the resume auto-follow pattern API. When it resumes, the auto-follow pattern is active again and automatically configures follower indices for newly created indices on the remote cluster that match its patterns. Remote indices that were created while the pattern was paused will also be followed, unless they have been deleted or closed in the interim.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-pause-auto-follow-pattern.html

    Parameters:

      - name (str) – The name of the auto follow pattern that should pause discovering new indices to follow.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  pause_follow(*, index, error_trace=None, filter_path=None, human=None, pretty=None)

    Pause a follower. Pause a cross-cluster replication follower index. The follower index will not fetch any additional operations from the leader index. You can resume following with the resume follower API. You can pause and resume a follower index to change the configuration of the following task.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-post-pause-follow.html

    Parameters:

      - index (str) – The name of the follower index that should pause following its leader index.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  put_auto_follow_pattern(*, name, remote_cluster=None, error_trace=None, filter_path=None, follow_index_pattern=None, human=None, leader_index_exclusion_patterns=None, leader_index_patterns=None, max_outstanding_read_requests=None, max_outstanding_write_requests=None, max_read_request_operation_count=None, max_read_request_size=None, max_retry_delay=None, max_write_buffer_count=None, max_write_buffer_size=None, max_write_request_operation_count=None, max_write_request_size=None, pretty=None, read_poll_timeout=None, settings=None, body=None)

    Create or update auto-follow patterns. Create a collection of cross-cluster replication auto-follow patterns for a remote cluster. Newly created indices on the remote cluster that match any of the patterns are automatically configured as follower indices. Indices on the remote cluster that were created before the auto-follow pattern was created will not be auto-followed even if they match the pattern.

    This API can also be used to update auto-follow patterns. NOTE: Follower indices that were configured automatically before updating an auto-follow pattern will remain unchanged even if they do not match against the new patterns.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-put-auto-follow-pattern.html

    Parameters:

      - name (str) – The name of the collection of auto-follow patterns.

      - remote_cluster (str | None) – The remote cluster containing the leader indices to match against.

      - follow_index_pattern (str | None) – The name of follower index. The template {{leader_index}} can be used to derive the name of the follower index from the name of the leader index. When following a data stream, use {{leader_index}}; CCR does not support changes to the names of a follower data stream’s backing indices.

      - leader_index_exclusion_patterns (Sequence[str] | None) – An array of simple index patterns that can be used to exclude indices from being auto-followed. Indices in the remote cluster whose names are matching one or more leader_index_patterns and one or more leader_index_exclusion_patterns won’t be followed.

      - leader_index_patterns (Sequence[str] | None) – An array of simple index patterns to match against indices in the remote cluster specified by the remote_cluster field.

      - max_outstanding_read_requests (int | None) – The maximum number of outstanding reads requests from the remote cluster.

      - max_outstanding_write_requests (int | None) – The maximum number of outstanding reads requests from the remote cluster.

      - max_read_request_operation_count (int | None) – The maximum number of operations to pull per read from the remote cluster.

      - max_read_request_size (int | str | None) – The maximum size in bytes of per read of a batch of operations pulled from the remote cluster.

      - max_retry_delay (str | Literal[-1] | ~typing.Literal[0] | None) – The maximum time to wait before retrying an operation that failed exceptionally. An exponential backoff strategy is employed when retrying.

      - max_write_buffer_count (int | None) – 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 (int | str | None) – 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 (int | None) – The maximum number of operations per bulk write request executed on the follower.

      - max_write_request_size (int | str | None) – The maximum total bytes of operations per bulk write request executed on the follower.

      - read_poll_timeout (str | Literal[-1] | ~typing.Literal[0] | None) – 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.

      - settings (Mapping[str, Any] | None) – Settings to override from the leader index. Note that certain settings can not be overrode (e.g., index.number_of_shards).

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  resume_auto_follow_pattern(*, name, error_trace=None, filter_path=None, human=None, pretty=None)

    Resume an auto-follow pattern. Resume a cross-cluster replication auto-follow pattern that was paused. The auto-follow pattern will resume configuring following indices for newly created indices that match its patterns on the remote cluster. Remote indices created while the pattern was paused will also be followed unless they have been deleted or closed in the interim.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-resume-auto-follow-pattern.html

    Parameters:

      - name (str) – The name of the auto follow pattern to resume discovering new indices to follow.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  resume_follow(*, index, error_trace=None, filter_path=None, human=None, max_outstanding_read_requests=None, max_outstanding_write_requests=None, max_read_request_operation_count=None, max_read_request_size=None, max_retry_delay=None, max_write_buffer_count=None, max_write_buffer_size=None, max_write_request_operation_count=None, max_write_request_size=None, pretty=None, read_poll_timeout=None, body=None)

    Resume a follower. Resume a cross-cluster replication follower index that was paused. The follower index could have been paused with the pause follower API. Alternatively it could be paused due to replication that cannot be retried due to failures during following tasks. When this API returns, the follower index will resume fetching operations from the leader index.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-post-resume-follow.html

    Parameters:

      - index (str) – The name of the follow index to resume following.

      - max_outstanding_read_requests (int | None)

      - max_outstanding_write_requests (int | None)

      - max_read_request_operation_count (int | None)

      - max_read_request_size (str | None)

      - max_retry_delay (str | Literal[-1] | ~typing.Literal[0] | None)

      - max_write_buffer_count (int | None)

      - max_write_buffer_size (str | None)

      - max_write_request_operation_count (int | None)

      - max_write_request_size (str | None)

      - read_poll_timeout (str | Literal[-1] | ~typing.Literal[0] | None)

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

      - body (Dict[str, Any] | None)

    Return type:

      ObjectApiResponse[Any]

  stats(*, error_trace=None, filter_path=None, human=None, pretty=None)

    Get cross-cluster replication stats. This API returns stats about auto-following and the same shard-level stats as the get follower stats API.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-get-stats.html

    Parameters:

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]

  unfollow(*, index, error_trace=None, filter_path=None, human=None, pretty=None)

    Unfollow an index. Convert a cross-cluster replication follower index to a regular index. The API stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. The follower index must be paused and closed before you call the unfollow API.

    NOTE: Currently cross-cluster replication does not support converting an existing regular index to a follower index. Converting a follower index to a regular index is an irreversible operation.

    https://www.elastic.co/guide/en/elasticsearch/reference/8.17/ccr-post-unfollow.html

    Parameters:

      - index (str) – The name of the follower index that should be turned into a regular index.

      - error_trace (bool | None)

      - filter_path (str | Sequence[str] | None)

      - human (bool | None)

      - pretty (bool | None)

    Return type:

      ObjectApiResponse[Any]