New ES Java API: Getting index name from alias name

I dont really understand how to get index name from alias name looking only at the api code of new elastic Java API.

I cannot find any document also.

Hope somebody here have tried.

Here`s what I tried so far:

final GetAliasRequest req = new GetAliasRequest.Builder().build();  ----> but I dont know where to specify the alias name

final GetAliaseResponse res = client.indices().getAlias(req)  ;  ---> not sure also here

-----> dont know what follows

Any help is appreciated.

What I want is how to implement this in code

GET _alias/aliasName

I will answer my own question hahaha, I discover it:

GetAliasRequest request = new GetAliasRequest.Builder().name(aliasName).build();
GetAliasResponse response = client.indices().getAlias(request);

String indexName = response.result.keySet().stream().findFirst();

That's it!

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