# Create initial index using aliases with ISM

**URL:** <https://forum.opensearch.org/t/create-initial-index-using-aliases-with-ism/8809>\
**Category:** Index Management\
**Tags:** troubleshoot\
**Created:** [March 3, 2022, 9:59am UTC](https://forum.opensearch.org/t/create-initial-index-using-aliases-with-ism/8809 "2022-03-03T09:59:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metheny](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Metheny](https://forum.opensearch.org/u/Metheny)\
**Post date:** [March 3, 2022, 9:59am UTC](https://forum.opensearch.org/t/create-initial-index-using-aliases-with-ism/8809/1 "2022-03-03T09:59:49Z")

</div>

I’m new to ISM, and wondering how do use ISM to create the initial index using an ISM policy.  
Note I cannot create the index manually, since we are creating different index groups on the fly.  
My goal is that when I write in my backend code that uses the alias for writing, the initial backing index will be created automatically. But I can’t get it to work.

This is the backend code:

```auto
client.index({
  index: 'my_alias',
 body: {
   prop: 'joe'
 })

```

I created the following policy and index template:

```PUT
{
  "policy": {
    "default_state": "open",
    "ism_template": {
      "index_patterns": ["ppp*"],
      "priority": 100
    },
    "states": [ {
      "name": "open"
    }]
  }
}

PUT _template/ppp_template
{
  "index_patterns": ["ppp*"], 
  "aliases": {
    "my_alias": {
    }
  }
}

```

But when I try to index a document to `my_alias` I get the following error:

> {  
> “error” : {  
> “root\_cause” : [  
> {  
> “type” : “illegal\_state\_exception”,  
> “reason” : “index, alias, and data stream names need to be unique, but the following duplicates were found [pppx (alias of [pppx/StEAdDnHRButkRXs-otvqA]) conflicts with index]”  
> }  
> ],  
> “type” : “illegal\_state\_exception”,  
> “reason” : “index, alias, and data stream names need to be unique, but the following duplicates were found [pppx (alias of [pppx/StEAdDnHRButkRXs-otvqA]) conflicts with index]”  
> },  
> “status” : 500  
> }

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![dbbaughe](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dbbaughe](https://forum.opensearch.org/u/dbbaughe)\
**Post date:** [March 17, 2022, 4:28pm UTC](https://forum.opensearch.org/t/create-initial-index-using-aliases-with-ism/8809/2 "2022-03-17T16:28:34Z")

</div>

I don’t believe you can use an alias if there is no actual alias to use yet (even if you specified it in a template, it doesn’t mean a concrete one exists that maps to an index). In your backend code can you first create an index that starts with `ppp` which will then get created and have the alias attached and the ISM policy applied and then once that index creation is successful start using the alias?
