2016-04-28 69 views

回答

1

您可以获取在索引创建时存储的settings.index.creation_date值。

的卷曲度就可以使用容易得到它:

curl -XGET localhost:9200/your_index/_settings 

你得到:

{ 
    "your_index" : { 
    "settings" : { 
     "index" : { 
     "creation_date" : "1460663685415", <--- this is what you're looking for 
     "number_of_shards" : "5", 
     "number_of_replicas" : "1", 
     "version" : { 
      "created" : "1040599" 
     }, 
     "uuid" : "dIG5GYsMTueOwONu4RGSQw" 
     } 
    } 
    } 
} 

有了玩笑,你可以使用得到相同的值:

import io.searchbox.indices.settings.GetSettings; 

    GetSettings getSettings = new GetSettings.Builder().build(); 
    JestResult result = client.execute(getSettings); 

你可以然后使用JestResult为了找到creation_date

如果我可能会提出一些建议,curator将是一个非常方便的工具来实现你所需要的。

只需每天一次运行这个命令:

curator delete indices --older-than 1 --time-unit days 
+0

可以为您在客户端详细说明()管理(),荫无法得到它,通过JestClient.thanks您的回复。 – sweety

+0

对不起,我的错,我已经更新了我的答案 – Val

+0

我必须绝对使用Jest Client。 – sweety