gpt4 book ai didi

java - 如何获取所有别名形式ImmutableOpenMap >

转载 作者:行者123 更新时间:2023-12-03 02:19:10 27 4
gpt4 key购买 nike

我尝试通过如下代码获取es群集中的所有别名:

public Set<String> getAllExitAlias(int timeOut) {
Set<String> result = new HashSet<>();
try {
GetAliasesResponse response = eagleTcpClient.getClient().admin().indices().getAliases(new GetAliasesRequest("_all")).get(timeOut, TimeUnit.SECONDS);
ImmutableOpenMap<String, List<AliasMetaData>> aliasesMap = response.getAliases();
... how can i build the result set of alias with aliasesMap as upon?
} catch (Exception exp) {
throw new RuntimeException("Error! A error occur when query exit alias!");
}
}

最佳答案

我有代码的解决方案:

public Set<String> getAllExistAlias(int timeOut) {
Set<String> result = new HashSet<>();
try {
GetAliasesResponse response = eagleTcpClient.getClient().admin().indices().getAliases(new GetAliasesRequest("_all")).get(timeOut, TimeUnit.SECONDS);
ImmutableOpenMap<String, List<AliasMetaData>> aliasesMap = response.getAliases();
for (ObjectCursor<List<AliasMetaData>> curAliases : aliasesMap.values()) {
for (AliasMetaData aliasMeta: curAliases.value) {
result.add(aliasMeta.alias());
}
}
return result;
} catch (Exception exp) {
throw new RuntimeException("Error! A error occur when query exist alias!");
}
}

关于java - 如何获取所有别名形式ImmutableOpenMap <String,List <AliasMetaData >>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62909821/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com