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!
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!
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.
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();) {
// HERE IS THE REALINDEXNAME
String realIndexName = it.next();
}
thanks for your reply.
you can check xavierfacq's answer. I test the code ,and it's OK
thank you very much. it's OK
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.