In a two-stream design, the index name is the replication contract. Here is how we chose between aliases and index patterns, whether the site suffix can be automated, and how to make an app that breaks the contract fail loudly.
Part 2 showed the two-stream design: each site writes indices carrying its own suffix, and the other site follows them. That makes the index name the replication contract. This post covers the design decisions that keep the contract intact.
The contract
<family>_<site>_<yyyymm>, for example orders_east_202311. The site suffix decides which cluster leads the index and whether the other site's auto-follow pattern picks it up. The month decides retention.
Watch the clock. Elasticsearch stores dates in UTC. An application that computes the month in local time writes the first hours of each month into the previous month's index.
Writes: alias or explicit name
A write alias (say orders_east_write, with is_write_index on the current month's index) means the app never computes index names, and rollover moves the write index. The limits: an alias has exactly one write index, rollover runs locally on each cluster, and in a two-stream design each site needs its own write alias pointing at its own suffix.
What happens to aliases on the follower? Current Elastic docs say alias changes on a leader index replicate to its followers, but is_write_index is forced to false there, because followers can't take writes. So replication can't hand the other site a second write index. That was an open question in our original design. Confirm it on your version before you depend on it.
An explicit monthly name gives readable names and simple retention by name. The cost: the app must compute the name, and it needs the create_index privilege.
Reads: index pattern or read alias
An index pattern (orders_*) searches every local and replicated index that matches, with no upkeep when a new month or a new follower appears. The downsides: it also catches anything else that matches, such as a stray test index; you can't write through it; and a broad pattern fans out to many shards.
A read alias works across sites if the index template adds it (say orders_read) to every leader index, because alias membership replicates with the follower. That gives each site a global alias, which is also cleaner to scope permissions on. On 7.x we read through patterns, because they didn't depend on alias replication behavior.
Our rule: write through a site-local alias or exact name; read through a pattern or read alias that spans both sites.
Who creates the index: the app or ILM
This is the comparison we worked through in the design review.
| Criterion | App creates monthly indices | ILM rollover creates indices |
|---|---|---|
| Index names | Readable: orders_east_202311 | Counter or timestamp suffix; rollover is by age or size, not calendar month |
| Site suffix | From app config | Hard-coded into each cluster's bootstrap index and alias |
| Knowing where to write | App computes the current month | The write alias handles it |
| App privileges | Needs create_index (scope it) | Needs write on the alias only |
| Retention | External job or ILM delete phase | ILM |
| Typical failure | Wrong config produces a wrong name | Missing bootstrap makes writes fail |
Can the site suffix be automated without app config?
Yes. There are three ways, each with its own overhead.
- An ingest pipeline per cluster. The app writes to a site-agnostic landing index,
orders. That index'sdefault_pipelineuses thedate_index_nameprocessor with the prefixorders_east_on East andorders_west_on West, routing each document to the right monthly site index by its timestamp. App config is identical at both sites. The overhead: ingest work on every document; two pipelines that must stay identical apart from the prefix; target indices that are auto-created, so templates andaction.auto_create_indexmust allow the pattern; and if the pipeline is ever missing, documents land in the landing index, which nothing replicates. Alert whenever the landing index holds any documents, and test how privileges apply to rerouted writes on your version. - An ILM bootstrap per cluster. Bake the site into each cluster's bootstrap index and rollover alias. The app writes to the alias and never sees the suffix.
- App config with guardrails. The suffix comes from config, and the app refuses to start if it is empty.
We chose the third option for readable monthly names, with the guardrails below, and kept retention with the operations team.
Guardrails that make a wrong suffix fail loudly
A wrongly suffixed index doesn't raise an error. It simply never matches the other site's auto-follow pattern, so it never replicates. That is silent divergence, the worst kind. The fix is to make it a permissions error:
- A separate application user per site.
- A role per site that grants
create_index,index,writeandreadonly on that site's pattern, plusreadon the whole family. A misconfigured app gets a 403 instead of creating an index nobody follows. - The app refuses to start if its site suffix is missing.
- Retention belongs to the platform team, not the app.
- The same index template on both clusters: mappings, the timestamp field, and the retention lease. CCR doesn't replicate templates, and followers take their mappings from the leader.
POST /_security/role/orders_app_east { "indices": [ { "names": ["orders_east*"], "privileges": ["create_index", "index", "write", "read"] }, { "names": ["orders_*"], "privileges": ["read"] } ] } Risks and precautions
- A wrong suffix means silent non-replication. Make it a 403.
- Compute month boundaries in UTC.
- Index patterns fan out. Keep families tight and size your shards.
- If you route with an ingest pipeline, alert on the landing index.
- Verify alias replication on your version before relying on a global read alias.
Part 4 of 8 in Elasticsearch Replication & DR Field Notes . Previous: Part 3, the settings that bite. Next: Part 5, CCR Meets ILM.




