May be with: if(!res.isExists())
:) David > Le 12 déc. 2014 à 01:37, Saurabh Saxena <[email protected]> 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 [email protected]. > 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 [email protected]. 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.
