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.
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.
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.
On Thursday, December 11, 2014 10:09:11 PM UTC-8, David Pilato wrote:
May be with:
if(!res.isExists())
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.
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())
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.
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())
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.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.