Remove postfix of indices name on Restore

I have a snapshot of an Elasticsearch cluster which has a number of indices. I have to restore the cluster on a new Elasticsearch cluster.

All the indices have a -reindexed postfix as part of their name. What I need to do is on Restore, I need to remove the -reindexed postfix for all of the indices. I am trying to use the rename_pattern and rename_replacement but due to my indices not having a standardized name I am not really sure how I can remove part of the name of all the indices using the above parameters.

POST /_snapshot/upgrade-snapshot/upgradesnapshot/_restore
{
  
  "indices": "process-reindexed, test-index-reindexed, test2-index-reindexed", 
  "rename_pattern": "*_(.+)",
  "rename_replacement": "restored_index_$1"
}

Ideally on the above query I need on Restore to remove the -reindexed postfix from all of my indices using rename_pattern and rename_replacement.

Thanks in advance!

Are you looking for something like this?

POST /_snapshot/upgrade-snapshot/upgradesnapshot/_restore
{
  
  "indices": "process-reindexed, test-index-reindexed, test2-index-reindexed", 
  "rename_pattern": "(*)-reindexed",
  "rename_replacement": "$1"
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.