# Invalid index name

**URL:** <https://discuss.elastic.co/t/invalid-index-name/111131>\
**Category:** Elasticsearch\
**Created:** [December 11, 2017, 3:28pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131 "2017-12-11T15:28:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)\
**Post date:** [December 11, 2017, 3:28pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/1 "2017-12-11T15:28:51Z")

</div>

I have a 3 nodes cluster with 1 primary shards on 1 node and 1 replica on each other node.  
My index has a name and an alias "current".  
I am bulk inserting into the master only via the alias name "current".  
That's working just fine. When my test kills the master in order to check failover,  
the next time I try to bulk insert I get Invalid index name [current], already exists as alias:

```
    ERROR 2017-12-11 11:22:23,310 [EventPublisher~i58] : 
    ElasticManagementClient(ElasticManagementClient.create:290) - failure in bulk 
    execution:
    [0]: index [current], type [events], id [349], message 
    [RemoteTransportException[[node-1][172.16.65.157:9300][indices:admin/create]]; 
    nested: InvalidIndexNameException[Invalid index name [current], already exists as 
    alias];]

```

What is the problem?

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 11, 2017, 4:00pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/2 "2017-12-11T16:00:58Z")

</div>

@Alex_Davidovich which version of ES are you using?

---

<div class="post-metadata">

**Author:** ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)\
**Post date:** [December 11, 2017, 4:02pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/3 "2017-12-11T16:02:25Z")

</div>

5.4.1

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 11, 2017, 4:21pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/4 "2017-12-11T16:21:33Z")

</div>

OK. Do you set the minimum\_master\_node setting? I'm curious why the node that received an indexing command for the `current` index/alias decided it needs to reach out to the master to create the index. Normally it should know the alias exist because it's part of the cluster.

---

<div class="post-metadata">

**Author:** ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)\
**Post date:** [December 11, 2017, 4:45pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/5 "2017-12-11T16:45:20Z")

</div>

@bleskes

```
 discovery.zen.minimum_master_nodes: 2
 discovery.zen.ping_timeout: 1s
 transport.tcp.connect_timeout: 5s

```

I just want to add that I am using transport client and this is my code:

```auto
for (Map.Entry<Long, String> eventJson : eventJsons.entrySet()) {

 indexRequestBuilder = client().prepareIndex(EventsConstants.CURRENT_ALIAS, EventsConstants.BASE_TYPE, eventJson.getKey().toString());
 bulkRequestBuilder.add(indexRequestBuilder.setSource(eventJson.getValue(), XContentType.JSON).setCreate(true).setTimeout(TIMEOUT));
}

```

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 11, 2017, 6:37pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/6 "2017-12-11T18:37:20Z")

</div>

Thanks @Alex_Davidovich. This is a two layered bug. First there should not be an attempt to create an index before the node fully joined the cluster. On top of that, once such an attempt fails, it shouldn't fail the indexing operation. We will open an issue and fix this. Thanks for bringing it up!

---

<div class="post-metadata">

**Author:** ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)\
**Post date:** [December 11, 2017, 6:45pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/7 "2017-12-11T18:45:37Z")

</div>

Thank you but I think that I don't fully understand.  
First of all, I am trying to index a document and not create an index. So why is ES trying to create one? In addition, do you think that a sleep + retry will be enough yo bypass the problem? Is there a way to figure out that ES is failing over via API?

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 11, 2017, 7:59pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/8 "2017-12-11T19:59:55Z")

</div>

> So why is ES trying to create one?

This is a default ES behavior. See [Index API | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-creation) for details and how to change that.

> In addition, do you think that a sleep + retry will be enough yo bypass the problem

that should by pass the problem. An alternative is disable auto index creation.

---

<div class="post-metadata">

**Author:** ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)\
**Post date:** [December 11, 2017, 8:03pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/9 "2017-12-11T20:03:13Z")

</div>

Thank you, but why ES doesn't that the index and alias do exist? Bug or expected behavior suring fail-over?

---

<div class="post-metadata">

**Author:** ![bleskes](https://avatars.discourse-cdn.com/v4/letter/b/71c47a/32.png) [@bleskes](https://discuss.elastic.co/u/bleskes)\
**Post date:** [December 11, 2017, 8:07pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/10 "2017-12-11T20:07:06Z")

</div>

> Bug or expected behavior suring fail-over?

This is a bug. I presume you restart the master? When the node starts up it forgets what it had and needs to rejoin the cluster. Any indexing during that period will run into this problem

---

<div class="post-metadata">

**Author:** ![Alex\_Davidovich](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@Alex\_Davidovich](https://discuss.elastic.co/u/Alex_Davidovich)\
**Post date:** [December 11, 2017, 8:10pm UTC](https://discuss.elastic.co/t/invalid-index-name/111131/11 "2017-12-11T20:10:16Z")

</div>

I am not sure whether or not the test restarts the node or only kills it, but thats good to know. Thank you very much for the help

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [December 12, 2017, 1:19am UTC](https://discuss.elastic.co/t/invalid-index-name/111131/12 "2017-12-12T01:19:01Z")

</div>

Thanks for reporting this! I've opened an issue for it at [https://github.com/elastic/elasticsearch/issues/27767](https://github.com/elastic/elasticsearch/issues/27767) and I'll work on a fix for this.

---

<div class="post-metadata">

**Author:** ![bmwmaestoso](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bmwmaestoso](https://discuss.elastic.co/u/bmwmaestoso)\
**Post date:** [December 16, 2017, 3:55am UTC](https://discuss.elastic.co/t/invalid-index-name/111131/13 "2017-12-16T03:55:52Z")

</div>

I have had the same error occur when doing a rollover and it seems to happen at random.

---

<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:** [January 13, 2018, 3:56am UTC](https://discuss.elastic.co/t/invalid-index-name/111131/14 "2018-01-13T03:56:01Z")

</div>

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