# Index missing error Eelasticseach java

**URL:** <https://discuss.elastic.co/t/index-missing-error-eelasticseach-java/18427>\
**Category:** Elasticsearch\
**Created:** [July 1, 2014, 10:35pm UTC](https://discuss.elastic.co/t/index-missing-error-eelasticseach-java/18427 "2014-07-01T22:35:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![venuchitta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venuchitta/32/1439_2.png) [@venuchitta](https://discuss.elastic.co/u/venuchitta)\
**Post date:** [July 1, 2014, 10:35pm UTC](https://discuss.elastic.co/t/index-missing-error-eelasticseach-java/18427/1 "2014-07-01T22:35:06Z")

</div>

Hi,

```
I am new to elasticsearch. I am using JAVA Api to establish connection with ES.

```

public void createIndex(final String index) {  
getClient().admin().indices().prepareCreate(index).execute().actionGet();  
}

public void createLocalCluster(final String clusterName) {  
NodeBuilder builder = NodeBuilder.nodeBuilder();  
Settings settings = ImmutableSettings.settingsBuilder()  
.put("gateway.type", "none")  
.put("cluster.name", clusterName)  
.build();  
builder.settings(settings).local(false).data(true);  
this.node = builder.node();  
this.client = node.client();   
}

```
public boolean existsIndex(final String index) {
	IndicesExistsResponse response = getClient().admin().indices().prepareExists(index).execute().actionGet();
	return response.isExists();		
}

```

public void openIndex(String name){  
getClient().admin().indices().prepareOpen(name).execute().actionGet();  
}

createLocalCluster("cerES");  
createIndex("news");  
System.out.println(existsIndex("news"));

When i execute the above java code iam getting "true" response. But when i close the java program and start the program again with the following code:  
openIndex("news");

It is throwing IndexMissingException.But i can see the news index in Data folder of eclipse. So how i retreive data from the node previously?. Is it lost? or am i wrong somewhere?

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 2, 2014, 2:01pm UTC](https://discuss.elastic.co/t/index-missing-error-eelasticseach-java/18427/2 "2014-07-02T14:01:03Z")

</div>

Use gateway type "local" instead of "none", then your index persists across  
cluster restarts.

Jörg

On Wed, Jul 2, 2014 at 12:35 AM, venuchitta [venu.chitta1992@gmail.com](mailto:venu.chitta1992@gmail.com)  
wrote:

> Hi,
> 
> ```
> I am new to elasticsearch. I am using JAVA Api to establish connection
> 
> ```
> 
> with ES.
> 
> public void createIndex(final String index) {
> 
> getClient().admin().indices().prepareCreate(index).execute().actionGet();  
> }
> 
> public void createLocalCluster(final String clusterName) {  
> NodeBuilder builder = NodeBuilder.nodeBuilder();  
> Settings settings = ImmutableSettings.settingsBuilder()  
> .put("gateway.type", "none")  
> .put("cluster.name", clusterName)  
> .build();  
> builder.settings(settings).local(false).data(true);  
> this.node = builder.node();  
> this.client = node.client();  
> }
> 
> ```
> public boolean existsIndex(final String index) {
> IndicesExistsResponse response =
> 
> ```
> 
> getClient().admin().indices().prepareExists(index).execute().actionGet();  
> return response.isExists();  
> }
> 
> public void openIndex(String name){
> 
> getClient().admin().indices().prepareOpen(name).execute().actionGet();  
> }
> 
> createLocalCluster("cerES");  
> createIndex("news");  
> System.out.println(existsIndex("news"));
> 
> When i execute the above java code iam getting "true" response. But when i  
> close the java program and start the program again with the following code:  
> openIndex("news");
> 
> It is throwing IndexMissingException.But i can see the news index in Data  
> folder of eclipse. So how i retreive data from the node previously?. Is it  
> lost? or am i wrong somewhere?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Index-missing-error-Eelasticseach-java-tp4059080.html](http://elasticsearch-users.115913.n3.nabble.com/Index-missing-error-Eelasticseach-java-tp4059080.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1404254107251-4059080.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1404254107251-4059080.post%40n3.nabble.com)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGd%2BG%3DEhY2LHeH27ujsw0%2B4\_%3DpPZoW3qkd8Grxe416Wdw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoGd%2BG%3DEhY2LHeH27ujsw0%2B4_%3DpPZoW3qkd8Grxe416Wdw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![venuchitta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venuchitta/32/1439_2.png) [@venuchitta](https://discuss.elastic.co/u/venuchitta)\
**Post date:** [July 2, 2014, 11:23pm UTC](https://discuss.elastic.co/t/index-missing-error-eelasticseach-java/18427/3 "2014-07-02T23:23:42Z")

</div>

Thank You for your help.

---

<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 6, 2017, 1:18am UTC](https://discuss.elastic.co/t/index-missing-error-eelasticseach-java/18427/4 "2017-07-06T01:18:15Z")

</div>


