How to get index is exist in elastic cluster?


(Sam-4) #1

Hi

I Have situation where i want to delete index from cluster.before i
need to check the availability of index in elastic server.if it
available then go for delete an index.please tell me how to get the
index exist in cluster using elastic java library.

Thanks


(Kun Niu) #2

You can try to IndicesExistsRequest and IndicesExistsResponse to verify
that.
You can build the request using IndicesAdminClient.
I had ever used it and it worked for me.

-----Original Message-----
From: elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] On Behalf Of sam
Sent: 2011年8月26日 14:43
To: elasticsearch
Subject: how to get index is exist in elastic cluster?

Hi

I Have situation where i want to delete index from cluster.before i need
to
check the availability of index in elastic server.if it available then go
for delete
an index.please tell me how to get the index exist in cluster using
elastic java
library.

Thanks


(David Pilato) #3

You can also delete the index and only catch the IndexMissingException.

David :wink:

Le 26 août 2011 à 08:42, sam mishra.sameek@gmail.com a écrit :

Hi

I Have situation where i want to delete index from cluster.before i
need to check the availability of index in elastic server.if it
available then go for delete an index.please tell me how to get the
index exist in cluster using elastic java library.

Thanks


(Kun Niu) #4

Just pay attention that it is a remote exception.

-----Original Message-----
From: elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: 2011年8月26日 15:05
To: elasticsearch@googlegroups.com
Subject: Re: how to get index is exist in elastic cluster?

You can also delete the index and only catch the IndexMissingException.

David :wink:

Le 26 août 2011 à 08:42, sam mishra.sameek@gmail.com a écrit :

Hi

I Have situation where i want to delete index from cluster.before i
need to check the availability of index in elastic server.if it
available then go for delete an index.please tell me how to get the
index exist in cluster using elastic java library.

Thanks


(David Pilato) #5

I'm sorry I have to disagree.

Here is what I wrote to force delete an index.

	try {
		node.client().admin().indices()
				.delete(new DeleteIndexRequest("myindexname")).actionGet();
	} catch (IndexMissingException e) {
		// Index does not exist... Fine
	}

As you can see, I catch the IndexMissingException which grand grand grand parent is a RuntimeException.

David.

-----Message d'origine-----
De : elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com] De la part de Kun Niu
Envoyé : vendredi 26 août 2011 09:06
À : elasticsearch@googlegroups.com
Objet : RE: how to get index is exist in elastic cluster?

Just pay attention that it is a remote exception.

-----Original Message-----
From: elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: 2011年8月26日 15:05
To: elasticsearch@googlegroups.com
Subject: Re: how to get index is exist in elastic cluster?

You can also delete the index and only catch the IndexMissingException.

David :wink:

Le 26 août 2011 à 08:42, sam mishra.sameek@gmail.com a écrit :

Hi

I Have situation where i want to delete index from cluster.before i
need to check the availability of index in elastic server.if it
available then go for delete an index.please tell me how to get the
index exist in cluster using elastic java library.

Thanks


(Shay Banon) #6

You might get it wrapped in a RemoteException as well, if it ended up coming
from another node. The remove exception thingy is very handy when it comes
to debugging (has a trace of all the nodes that the failure came from), but,
it does not work amazingly well with java catch clauses... .

On Fri, Aug 26, 2011 at 7:21 PM, David Pilato david@pilato.fr wrote:

I'm sorry I have to disagree.

Here is what I wrote to force delete an index.

           try {
                   node.client().admin().indices()
                                   .delete(new

DeleteIndexRequest("myindexname")).actionGet();
} catch (IndexMissingException e) {
// Index does not exist... Fine
}

As you can see, I catch the IndexMissingException which grand grand grand
parent is a RuntimeException.

David.

-----Message d'origine-----
De : elasticsearch@googlegroups.com [mailto:elasticsearch@googlegroups.com]
De la part de Kun Niu
Envoyé : vendredi 26 août 2011 09:06
À : elasticsearch@googlegroups.com
Objet : RE: how to get index is exist in elastic cluster?

Just pay attention that it is a remote exception.

-----Original Message-----
From: elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] On Behalf Of David Pilato
Sent: 2011年8月26日 15:05
To: elasticsearch@googlegroups.com
Subject: Re: how to get index is exist in elastic cluster?

You can also delete the index and only catch the IndexMissingException.

David :wink:

Le 26 août 2011 à 08:42, sam mishra.sameek@gmail.com a écrit :

Hi

I Have situation where i want to delete index from cluster.before i
need to check the availability of index in elastic server.if it
available then go for delete an index.please tell me how to get the
index exist in cluster using elastic java library.

Thanks


(system) #7