Change index alias

Hi,
Previously I have created an index alias tests

PUT tests-00000001
{
  "aliases": {
    "tests": {
      "is_write_index": true
    }
  }
}

I have used it as rollover alias to create an index template

PUT _index_template/tests-template
{
  "template": {
    "settings": {
      "index": {
        "lifecycle": {
          "name": "test-policy",
          "rollover_alias": "tests"
        },
        "number_of_shards": "5",
        "number_of_replicas": "1"
      }
    },
    "mappings": {
      "properties": {
        "test-name": {
          "type": "keyword"
        },
        "@timestamp": {
          "type": "date_nanos"
        },
        "result": {
          "type": "integer"
        }
      }
    }
  },
  "index_patterns": ["tests-*"]
}

This is working as it should and now I have two indices tests-00000001 and tests-00000002

Now I have to change the pattern to include the date instead of just a number so the index names should be something like: tests-2021.07.11
How can I achieve this without loosing my already indexed data?

I know that this is how I can introduce the new alias and index names:

PUT /%3Ctests-%7Bnow%2Fd%7D%3E
{
  "aliases": {
    "tests": {
      "is_write_index": true
    }
  }
}

Is it possible to re-index the already indexed data into indices that follows the new naming convention?

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