Get index by alias java api

(Hrdxwandg) #1

how to get actual index name by index alias name with java api.
the version of es is 2.4.0

for your help! thank you ahead!

(Mark Harwood) #2

I had a quick look and couldn't see a specific API for this.
You could always run a search with size 1 and the physical index name should be returned as part of matching documents' properties.

(Xavier Facq) #3

My code is:

		// get name of the current index where the alias is active
		GetAliasesResponse r = client.admin().indices().getAliases(new GetAliasesRequest().aliases("YOUR_ALIAS")).get();

		for(Iterator<String> it = r.getAliases().keysIt(); it.hasNext();) {
			String realIndexName =;

(Hrdxwandg) #4

thanks for your reply.

you can check xavierfacq's answer. I test the code ,and it's OK

(Hrdxwandg) #5

thank you very much. it's OK

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.