What's the best way in java or groovy to determine the existence of an index given it's name

Hi Folks,
There's code in our base (I didnt write, but inherited) like this,
seems like there has to be a better way?
Also when instantiating a new IndexStatusRequest, does the resulting
object contains all the known indexes?
Is there a true javadoc on this "low level" stuff
The only think related on the site I saw was this
http://www.elasticsearch.com/docs/elasticsearch/java_api/admin/
I've resorted to looking at method sigs (in my ide) and guessing
Is there a best way to build the javadoc?

BTW were upgrading from .9 to .12.1
Thanks
Gideon

private boolean testIndexExists(indexName) {
def statusResponse
boolean retValue = false

    try {
        statusResponse = client.admin().indices().status(new

IndicesStatusRequest()).actionGet() // check first to see if it
doesn't exist or get an exception if trying to create existing
if (statusResponse.index(indexName) != null) retValue =
true //statusRespopnse if of type IndexStatusResponse -
public org.elasticsearch.action.admin.indices.status.IndexStatus
index(java.lang.String index) { /* compiled code */ }
} catch(IndexMissingException ime) { // I used to be able to
check the statusresponse now I will get an IME so treat both the same
logger.debug "Hit an indexedmissingexception in index
test"
retValue = false
}

http://elasticsearch-users.115913.n3.nabble.com/Finding-out-if-an-index-exists-td1820921.html#a1820921

On Tue, Nov 9, 2010 at 8:03 PM, Gideon Kaplan gideonkaplan@gmail.comwrote:

Hi Folks,
There's code in our base (I didnt write, but inherited) like this,
seems like there has to be a better way?
Also when instantiating a new IndexStatusRequest, does the resulting
object contains all the known indexes?
Is there a true javadoc on this "low level" stuff
The only think related on the site I saw was this
http://www.elasticsearch.com/docs/elasticsearch/java_api/admin/
I've resorted to looking at method sigs (in my ide) and guessing
Is there a best way to build the javadoc?

BTW were upgrading from .9 to .12.1
Thanks
Gideon

private boolean testIndexExists(indexName) {
def statusResponse
boolean retValue = false

   try {
       statusResponse = client.admin().indices().status(new

IndicesStatusRequest()).actionGet() // check first to see if it
doesn't exist or get an exception if trying to create existing
if (statusResponse.index(indexName) != null) retValue =
true //statusRespopnse if of type IndexStatusResponse -
public org.elasticsearch.action.admin.indices.status.IndexStatus
index(java.lang.String index) { /* compiled code */ }
} catch(IndexMissingException ime) { // I used to be able to
check the statusresponse now I will get an IME so treat both the same
logger.debug "Hit an indexedmissingexception in index
test"
retValue = false
}

Thanks James

On Nov 9, 5:47 pm, James Cook jc...@tracermedia.com wrote:

http://elasticsearch-users.115913.n3.nabble.com/Finding-out-if-an-ind...

On Tue, Nov 9, 2010 at 8:03 PM, Gideon Kaplan gideonkap...@gmail.comwrote:

Hi Folks,
There's code in our base (I didnt write, but inherited) like this,
seems like there has to be a better way?
Also when instantiating a new IndexStatusRequest, does the resulting
object contains all the known indexes?
Is there a true javadoc on this "low level" stuff
The only think related on the site I saw was this
http://www.elasticsearch.com/docs/elasticsearch/java_api/admin/
I've resorted to looking at method sigs (in my ide) and guessing
Is there a best way to build the javadoc?

BTW were upgrading from .9 to .12.1
Thanks
Gideon

private boolean testIndexExists(indexName) {
def statusResponse
boolean retValue = false

   try {
       statusResponse = client.admin().indices().status(new

IndicesStatusRequest()).actionGet() // check first to see if it
doesn't exist or get an exception if trying to create existing
if (statusResponse.index(indexName) != null) retValue =
true //statusRespopnse if of type IndexStatusResponse -
public org.elasticsearch.action.admin.indices.status.IndexStatus
index(java.lang.String index) { /* compiled code */ }
} catch(IndexMissingException ime) { // I used to be able to
check the statusresponse now I will get an IME so treat both the same
logger.debug "Hit an indexedmissingexception in index
test"
retValue = false
}