Reindexing takes 30 seconds and I don't want my search to be offline for 30 seconds every time I need to reindex. I'm trying to do this:
I can't seem to find any java code that does 1). Everything else is fine. Anyone? or is there another way that is better?
Using Elasticsearch 0.90.9.
Here is the method for your reference for finding all indices in a given aliasName:
public Set<String> getIndicesFromAliasName(String aliasName) {
IndicesAdminClient iac = client.admin().indices();
ImmutableOpenMap<String, List<AliasMetaData>> map = iac.getAliases(new GetAliasesRequest(aliasName))
.actionGet().getAliases();
final Set<String> allIndices = new HashSet<>();
map.keysIt().forEachRemaining(allIndices::add);
return allIndices;
}
You can use this to get all of the aliases:
client.admin().cluster()
.prepareState().execute()
.actionGet().getState()
.getMetaData().getAliases();
This returns a map with the index name as the key
and the aliases
as the value. So you can iterate over the map to get the index name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With