0

想要使用 JAVA 中的日期数学表达式删除比某些特定(比如说 30)天更早的弹性搜索上的基于时间的索引。

尝试使用 Transaport Client 在我们的 Spring Boot 应用程序中实现以下方法,但获取索引不存在异常。
https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html

当在 kibana 上使用查询 GET uri_encoded_index_name 使用相同的 URI 编码索引名称(传递给 DELETE INDEX API)来搜索索引时,它表明索引存在。

有什么我错过了吗?
在不使用馆长和通配符的情况下,有没有更好的方法来做到这一点?

代码片段:

String indexName = "<" + indexNameStaticPart + "{now/d-30d{MMddYYYY}}>";     
String encodedIndexName = UriEncoder.encode( indexName ).replace( "/", "%2F" );      
AcknowledgedResponse response = client.admin().indices().delete( new DeleteIndexRequest( encodedIndexName ) ).actionGet();

编码索引名称:%3Cstring__string_string__%7Bnow%2Fd-30d%7BMMddyyyy%7D%7D%3E

基巴纳:

GET encodedIndexName 
DELETE encodedIndexName 
4