Open-Source Wikis

/

Elasticsearch

/

Features

/

Cross-cluster search and replication

elastic/elasticsearch

Cross-cluster search and replication

Two related capabilities that link clusters together:

  • CCS (Cross-Cluster Search) — a single search hits indices on multiple clusters and merges results.
  • CCR (Cross-Cluster Replication) — a follower cluster continuously pulls index changes from a leader cluster.

Both are built on top of RemoteClusterService (server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java).

Remote cluster connections

A node configured with cluster.remote.<alias>.seeds (or mode: proxy) opens a small pool of transport connections to the named remote cluster. Connections are dedicated channel types (reg and recovery) and are tracked separately from intra-cluster connections.

API:

  • PUT /_cluster/settings { "persistent": { "cluster.remote.eu.seeds": [...] } }
  • GET /_remote/info

CCS

GET /local-index,eu:logs-*/_search
{ "query": {...} }

TransportSearchAction recognizes the <cluster>:<index> prefix, splits the search into per-cluster sub-searches, and dispatches:

  • minimize_roundtrips: true (default): each remote runs the full two-phase search and returns final hits; the coordinator merges. Latency is one round-trip, but features like search_after across clusters are limited.
  • minimize_roundtrips: false: the coordinator participates in the per-shard query phase across clusters; more flexible, more network traffic.

Cross-cluster aggregations are reduced on the coordinator just like local ones; the partial-reduce step on the remote keeps payloads small.

ES|QL has its own cross-cluster path in x-pack/plugin/esql/ that uses the same RemoteClusterService connection pool.

CCR

x-pack/plugin/ccr/
├── src/main/java/org/elasticsearch/xpack/ccr/
│   ├── action/follow/                      Follower-side state machine
│   ├── action/leader/                      Leader-side shard changes API
│   ├── action/AutoFollowCoordinator.java   Auto-follow patterns
│   └── ...
└── ...

The follower opens a per-shard "follow task" (a persistent task) that pulls operations from the leader's translog/Lucene history via the ShardChangesAction. Operations are fed into the follower's IndexShard using the leader's seq-no/primary-term envelope, so primaries stay in causal sync.

graph LR
  L[Leader cluster] -->|ShardChangesAction| F[Follower cluster]
  F --> FT[FollowTask]
  FT --> FS[Follower IndexShard]

Auto-follow patterns let a follower automatically wrap any new index matching a pattern on the leader; this is how operators implement cross-region disaster recovery.

CCR is licensed (X-Pack); CCS is free.

CCR retention leases

The leader's translog must keep operations long enough for a follower to consume them. CCR uses retention leases (server/src/main/java/org/elasticsearch/index/seqno/): a follower holds a lease against a sequence number, and the leader's translog/global checkpoint promotion respects active leases.

Integration with security

Cross-cluster connections support API-key-based credentials (cluster.remote.<alias>.credentials); the leader cluster authenticates each follower API key and applies role-based authorization just like for local users.

Where to extend

  • CCS-aware action: implement RemoteClusterAware request handling; reuse RemoteClusterService.getConnection.
  • New retention strategy: see x-pack/plugin/ccr retention lease handling.
  • Tuning: cluster.remote.<alias>.transport.compress, ping_schedule, connections_per_cluster.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Cross-cluster search and replication – Elasticsearch wiki | Factory