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