Index missing error Eelasticseach java

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?

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
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
Sent from the Elasticsearch Users mailing list archive at 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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/1404254107251-4059080.post%40n3.nabble.com
.
For more options, visit 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.
To view this discussion on the web visit 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.

Thank You for your help.