# Getting IndexnotFound Exception java

**URL:** <https://discuss.elastic.co/t/getting-indexnotfound-exception-java/98327>\
**Category:** Elasticsearch\
**Created:** [August 25, 2017, 5:35am UTC](https://discuss.elastic.co/t/getting-indexnotfound-exception-java/98327 "2017-08-25T05:35:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishnudivakar31](https://avatars.discourse-cdn.com/v4/letter/v/58f4c7/32.png) [@vishnudivakar31](https://discuss.elastic.co/u/vishnudivakar31)\
**Post date:** [August 25, 2017, 5:35am UTC](https://discuss.elastic.co/t/getting-indexnotfound-exception-java/98327/1 "2017-08-25T05:35:08Z")

</div>

I am indexing a document using prepareIndex java API. And it is returning positive status. When I immediately call prepareSearch API it would return IndexNotFound exception. Please help me with this issue.

I tried adding delay of 1 second in between prepareIndex and prepareSearch then it would sometime work and sometime may not work.

Please give me some suggestions.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 25, 2017, 7:57am UTC](https://discuss.elastic.co/t/getting-indexnotfound-exception-java/98327/2 "2017-08-25T07:57:53Z")

</div>

This question is impossible to answer without a code sample. I suppose you are not waiting for the future of the create index API to return and so the search request sometimes finds an index and sometimes doesnt. But again, just a wild guess without any code.

---

<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:** [September 22, 2017, 7:58am UTC](https://discuss.elastic.co/t/getting-indexnotfound-exception-java/98327/3 "2017-09-22T07:58:04Z")

</div>

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