2016-04-28 67 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