IndicesExistsResponse.isExists() not working for embedded ElasticSearch instance

Hi,

I am using the following java code to create instance of ElasticSearch
instance and create a index called "testindex".

Node node =
NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
.put("path.data",
"/etc/elasticsearch")
.put("cluster.name",
"testcluster"))
.node();
Client client = node.client();
IndicesAdminClient indices = client.admin().indices();
IndicesExistsResponse res =
indices.prepareExists("testindex").execute().actionGet();
if(res.isExists()){ //Everytime getting value as false
CreateIndexRequestBuilder createIndexRequestBuilder =
indices.prepareCreate("testindex");
createIndexRequestBuilder.execute().actionGet(); // Erring out with
IndexAlreadyExistsException
}

Before creating the index I am checking whether index exists or not, I only
create the index if it exists.
Second time when I am running the above code, it fails with
IndexAlreadyExistsException.
It seems like the IndicesExistsResponse.isExists() is not behaving
correctly.

Above code works fine if default elasticsearch.yml file is present in the
classpath. IndicesExistResponse.isExists() returns true if
elasticsearch.yml is in the classpath.

Any workaround to resolve the issues ?

Regards,
Saurabh Saxena

--
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/7b7a3e91-b023-4412-8c59-504fdb427369%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I am using version v1.4.0.

On Thursday, December 11, 2014 4:30:23 PM UTC-8, Saurabh Saxena wrote:

Hi,

I am using the following java code to create instance of ElasticSearch
instance and create a index called "testindex".

Node node =
NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
.put("path.data",
"/etc/elasticsearch")
.put("cluster.name",
"testcluster"))
.node();
Client client = node.client();
IndicesAdminClient indices = client.admin().indices();
IndicesExistsResponse res =
indices.prepareExists("testindex").execute().actionGet();
if(res.isExists()){ //Everytime getting value as false
CreateIndexRequestBuilder createIndexRequestBuilder =
indices.prepareCreate("testindex");
createIndexRequestBuilder.execute().actionGet(); // Erring out with
IndexAlreadyExistsException
}

Before creating the index I am checking whether index exists or not, I
only create the index if it exists.
Second time when I am running the above code, it fails with
IndexAlreadyExistsException.
It seems like the IndicesExistsResponse.isExists() is not behaving
correctly.

Above code works fine if default elasticsearch.yml file is present in the
classpath. IndicesExistResponse.isExists() returns true if
elasticsearch.yml is in the classpath.

Any workaround to resolve the issues ?

Regards,
Saurabh Saxena

--
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/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

May be with:

if(!res.isExists())

:slight_smile:

David

Le 12 déc. 2014 à 01:37, Saurabh Saxena sausax@gmail.com a écrit :

I am using version v1.4.0.

On Thursday, December 11, 2014 4:30:23 PM UTC-8, Saurabh Saxena wrote:
Hi,

I am using the following java code to create instance of ElasticSearch instance and create a index called "testindex".

Node node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
.put("path.data", "/etc/elasticsearch")
.put("cluster.name", "testcluster"))
.node();
Client client = node.client();
IndicesAdminClient indices = client.admin().indices();
IndicesExistsResponse res = indices.prepareExists("testindex").execute().actionGet();
if(res.isExists()){ //Everytime getting value as false
CreateIndexRequestBuilder createIndexRequestBuilder = indices.prepareCreate("testindex");
createIndexRequestBuilder.execute().actionGet(); // Erring out with IndexAlreadyExistsException
}

Before creating the index I am checking whether index exists or not, I only create the index if it exists.
Second time when I am running the above code, it fails with IndexAlreadyExistsException.
It seems like the IndicesExistsResponse.isExists() is not behaving correctly.

Above code works fine if default elasticsearch.yml file is present in the classpath. IndicesExistResponse.isExists() returns true if elasticsearch.yml is in the classpath.

Any workaround to resolve the issues ?

Regards,
Saurabh Saxena

--
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/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.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/B9D0EA90-EC69-4EC1-92BD-024D480CB00F%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

Hi David,

I made mistake while copying, it is actually

if(!res.isExists())

  • Saurabh

On Thursday, December 11, 2014 10:09:11 PM UTC-8, David Pilato wrote:

May be with:

if(!res.isExists())

:slight_smile:

David

Le 12 déc. 2014 à 01:37, Saurabh Saxena <sau...@gmail.com <javascript:>>
a écrit :

I am using version v1.4.0.

On Thursday, December 11, 2014 4:30:23 PM UTC-8, Saurabh Saxena wrote:

Hi,

I am using the following java code to create instance of ElasticSearch
instance and create a index called "testindex".

Node node =
NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
.put("path.data",
"/etc/elasticsearch")
.put("cluster.name",
"testcluster"))
.node();
Client client = node.client();
IndicesAdminClient indices = client.admin().indices();
IndicesExistsResponse res =
indices.prepareExists("testindex").execute().actionGet();
if(res.isExists()){ //Everytime getting value as false
CreateIndexRequestBuilder createIndexRequestBuilder =
indices.prepareCreate("testindex");
createIndexRequestBuilder.execute().actionGet(); // Erring out with
IndexAlreadyExistsException
}

Before creating the index I am checking whether index exists or not, I
only create the index if it exists.
Second time when I am running the above code, it fails with
IndexAlreadyExistsException.
It seems like the IndicesExistsResponse.isExists() is not behaving
correctly.

Above code works fine if default elasticsearch.yml file is present in the
classpath. IndicesExistResponse.isExists() returns true if
elasticsearch.yml is in the classpath.

Any workaround to resolve the issues ?

Regards,
Saurabh Saxena

--
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.com?utm_medium=email&utm_source=footer
.
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/0f91ac48-e08a-47ff-9243-c69c5bffc470%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ha!

TBH I prefer to do a try catch (IndexAlreadyExistsException) then testing first.
Will try to reproduce your case.

Is it the actual code you are running?

David

Le 12 déc. 2014 à 08:32, Saurabh Saxena sausax@gmail.com a écrit :

Hi David,

I made mistake while copying, it is actually

if(!res.isExists())

  • Saurabh

On Thursday, December 11, 2014 10:09:11 PM UTC-8, David Pilato wrote:
May be with:

if(!res.isExists())

:slight_smile:

David

Le 12 déc. 2014 à 01:37, Saurabh Saxena sau...@gmail.com a écrit :

I am using version v1.4.0.

On Thursday, December 11, 2014 4:30:23 PM UTC-8, Saurabh Saxena wrote:
Hi,

I am using the following java code to create instance of ElasticSearch instance and create a index called "testindex".

Node node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
.put("path.data", "/etc/elasticsearch")
.put("cluster.name", "testcluster"))
.node();
Client client = node.client();
IndicesAdminClient indices = client.admin().indices();
IndicesExistsResponse res = indices.prepareExists("testindex").execute().actionGet();
if(res.isExists()){ //Everytime getting value as false
CreateIndexRequestBuilder createIndexRequestBuilder = indices.prepareCreate("testindex");
createIndexRequestBuilder.execute().actionGet(); // Erring out with IndexAlreadyExistsException
}

Before creating the index I am checking whether index exists or not, I only create the index if it exists.
Second time when I am running the above code, it fails with IndexAlreadyExistsException.
It seems like the IndicesExistsResponse.isExists() is not behaving correctly.

Above code works fine if default elasticsearch.yml file is present in the classpath. IndicesExistResponse.isExists() returns true if elasticsearch.yml is in the classpath.

Any workaround to resolve the issues ?

Regards,
Saurabh Saxena

--
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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.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/0f91ac48-e08a-47ff-9243-c69c5bffc470%40googlegroups.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/817A14A6-3902-4852-8EBF-6961A8026AC1%40pilato.fr.
For more options, visit https://groups.google.com/d/optout.

To move forward with my work I am catching IndexAlreadyExistsException and
ignoring it.
But I think this is bug.

Yes, this a actual code.
Added complete java file.

On Thursday, December 11, 2014 11:36:31 PM UTC-8, David Pilato wrote:

Ha!

TBH I prefer to do a try catch (IndexAlreadyExistsException) then testing
first.
Will try to reproduce your case.

Is it the actual code you are running?

David

Le 12 déc. 2014 à 08:32, Saurabh Saxena <sau...@gmail.com <javascript:>>
a écrit :

Hi David,

I made mistake while copying, it is actually

if(!res.isExists())

  • Saurabh

On Thursday, December 11, 2014 10:09:11 PM UTC-8, David Pilato wrote:

May be with:

if(!res.isExists())

:slight_smile:

David

Le 12 déc. 2014 à 01:37, Saurabh Saxena sau...@gmail.com a écrit :

I am using version v1.4.0.

On Thursday, December 11, 2014 4:30:23 PM UTC-8, Saurabh Saxena wrote:

Hi,

I am using the following java code to create instance of ElasticSearch
instance and create a index called "testindex".

Node node =
NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
.put("path.data",
"/etc/elasticsearch")
.put("cluster.name",
"testcluster"))
.node();
Client client = node.client();
IndicesAdminClient indices = client.admin().indices();
IndicesExistsResponse res =
indices.prepareExists("testindex").execute().actionGet();
if(res.isExists()){ //Everytime getting value as false
CreateIndexRequestBuilder createIndexRequestBuilder =
indices.prepareCreate("testindex");
createIndexRequestBuilder.execute().actionGet(); // Erring out with
IndexAlreadyExistsException
}

Before creating the index I am checking whether index exists or not, I
only create the index if it exists.
Second time when I am running the above code, it fails with
IndexAlreadyExistsException.
It seems like the IndicesExistsResponse.isExists() is not behaving
correctly.

Above code works fine if default elasticsearch.yml file is present in
the classpath. IndicesExistResponse.isExists() returns true if
elasticsearch.yml is in the classpath.

Any workaround to resolve the issues ?

Regards,
Saurabh Saxena

--
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 elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/38d97ae1-5df9-4c46-8cb5-e79f1d6c588d%40googlegroups.com?utm_medium=email&utm_source=footer
.
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 elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/0f91ac48-e08a-47ff-9243-c69c5bffc470%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/0f91ac48-e08a-47ff-9243-c69c5bffc470%40googlegroups.com?utm_medium=email&utm_source=footer
.
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/142f5f24-5331-42b7-b426-1102a4663fc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.