从ElasticSearch中获取与模式匹配的索引名称列表- JAVA

uemypmqf  于 5个月前  发布在  Java
关注(0)|答案(2)|浏览(53)

我在ElasticSearch中有一个索引列表,如下所示:

index1, index2, index3, test-index1, test-index2, test-index3

字符串
现在我只需要那些与我的模式“test-*"匹配的索引。
我可以通过下面的sense query来实现上面的结果:

GET test-*/_aliases


我想从Java代码中实现同样的结果。

fdx2calv

fdx2calv1#

响应/test-*/_aliases的REST端点执行以下操作(see here):

GetAliasesResponse getAliasesResponse = client().admin().indices()
        .prepareGetAliases()
        .setIndices("test-*", "index-*").get();

字符串

55ooxyrt

55ooxyrt2#

ES版本8更新。ES自2016年以来已经改变了很多。
这似乎不再是_aliases端点的工作方式。
要获取与模式匹配的索引列表,请执行以下操作:

https://localhost:9200/_cat/indices/test-*

字符串
我不知道特定语言中的ES客户端是如何做到这一点的。或者它的意义是什么:在Python中使用requests很好,在Rust中使用reqwests。在Java中似乎是类似的。

相关问题