# Time lag between Index creation and Index availability

**URL:** <https://discuss.elastic.co/t/time-lag-between-index-creation-and-index-availability/33724>\
**Category:** Elasticsearch\
**Created:** [November 4, 2015, 10:15am UTC](https://discuss.elastic.co/t/time-lag-between-index-creation-and-index-availability/33724 "2015-11-04T10:15:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![srkhanzode](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@srkhanzode](https://discuss.elastic.co/u/srkhanzode)\
**Post date:** [November 4, 2015, 10:15am UTC](https://discuss.elastic.co/t/time-lag-between-index-creation-and-index-availability/33724/1 "2015-11-04T10:15:10Z")

</div>

Hi,

We recently encountered issues for the following scenario:

On a standard 3-node cluster, we create a typical index with 4/5 mappings (each mapping with ~10-15 fields and some custom analyzers). Immediately after the index creation call in the Java client, we invoke the TransportClient to create at-least one record each. However, sometimes, we get an IndexMissingException when we insert a document in the created index.

I think the below is related, but since the thread is dated, I wanted to know whether there are other approaches.

> [@IndexMissingException on create index followed by refresh](https://discuss.elastic.co/t/indexmissingexception-on-create-index-followed-by-refresh/3505):
>
> Hi, I am seeing an IndexMissingException when I do an index create followed immediately by refresh. first of all, my setup is: ES 0.12.1 Java client API, embedded no-data node local gateway remote ES data node My pseudocode goes like this: create index (1 shard, 0 replica for batch indexing) add documents if any refresh flush optimize ... In my first attempt I didn't have documents in my DB, so create was followed by refresh without delay, in that case I am seeing: Exception in thread…

Thanks,  
SRK

---

<div class="post-metadata">

**Author:** ![saggarsunil](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@saggarsunil](https://discuss.elastic.co/u/saggarsunil)\
**Post date:** [November 4, 2015, 11:15am UTC](https://discuss.elastic.co/t/time-lag-between-index-creation-and-index-availability/33724/2 "2015-11-04T11:15:29Z")

</div>

As per the original question, i believe "index.refresh\_interval" dictates the time between indexed data to be available for search. The value is 1 sec, by default.

-Suni

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [November 4, 2015, 1:59pm UTC](https://discuss.elastic.co/t/time-lag-between-index-creation-and-index-availability/33724/3 "2015-11-04T13:59:21Z")

</div>

You are correct, there is a bit of a lag. The Create Index API is asynchronous, it will return as soon as the master has acknowledged the request (but not necessarily after the shards have been created on the individual nodes).

To prevent this kind of problem, you can wait for the status to return to yellow or green. During the brief moment that the shards are being created your cluster will be red, so it works as an effective block.

You can do this via the [cluster health api](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html#request-params): `GET localhost:9200/_cluster/health?wait_for_status=yellow`

This is basically how our integration tests circumvent this very issue.

---

<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:** [July 5, 2017, 11:40pm UTC](https://discuss.elastic.co/t/time-lag-between-index-creation-and-index-availability/33724/4 "2017-07-05T23:40:37Z")

</div>


