0
我試圖從24小時前創建的elasticsearch中刪除索引。我沒有找到一種方法來獲取特定節點的索引創建時間。使用彈簧啓動彈性搜索可以完成。但我正在使用Jest API。如何使用Jest在彈性搜索中獲取索引創建時間
我試圖從24小時前創建的elasticsearch中刪除索引。我沒有找到一種方法來獲取特定節點的索引創建時間。使用彈簧啓動彈性搜索可以完成。但我正在使用Jest API。如何使用Jest在彈性搜索中獲取索引創建時間
您可以獲取在索引創建時存儲的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
可以爲您在客戶端詳細說明()管理(),蔭無法得到它,通過JestClient.thanks您的回覆。 – sweety
對不起,我的錯,我已經更新了我的答案 – Val
我必須絕對使用Jest Client。 – sweety