# Change index alias

**URL:** <https://discuss.elastic.co/t/change-index-alias/278355>\
**Category:** Elasticsearch\
**Tags:** ilm-index-lifecycle-management\
**Created:** [July 11, 2021, 10:59am UTC](https://discuss.elastic.co/t/change-index-alias/278355 "2021-07-11T10:59:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![malsioufi](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@malsioufi](https://discuss.elastic.co/u/malsioufi)\
**Post date:** [July 11, 2021, 10:59am UTC](https://discuss.elastic.co/t/change-index-alias/278355/1 "2021-07-11T10:59:51Z")

</div>

Hi,  
Previously I have created an index alias `tests`

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

```

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

```auto
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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 8, 2021, 11:00am UTC](https://discuss.elastic.co/t/change-index-alias/278355/2 "2021-08-08T11:00:07Z")

</div>

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