I am trying to delete the indexes from elasticsearch which are created 24 hours before. I am not finding a way to get the creation time of indices for the particular node. Using spring boot elastic search, this can be accomplished. However, I am using the Jest API.
Asked
Active
Viewed 1,747 times
1 Answers
1
You can get the settings.index.creation_date
value that was stored at index creation time.
With curl you can get it easily using:
curl -XGET localhost:9200/your_index/_settings
You get:
{
"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"
}
}
}
}
With Jest, you can get the same value using:
import io.searchbox.indices.settings.GetSettings;
GetSettings getSettings = new GetSettings.Builder().build();
JestResult result = client.execute(getSettings);
You can then use JestResult
in order to find the creation_date
If I may suggest something, curator would be a much handier tool for achieving what you need.
Simply run this once a day:
curator delete indices --older-than 1 --time-unit days

Val
- 207,596
- 13
- 358
- 360
-
can you elaborate on client().admin() , Iam unable to get it, through JestClient.thanks for your reply. – sweety Apr 28 '16 at 11:45
-
I have to use Jest Client absolutely. – sweety Apr 28 '16 at 11:53
-
can you tell me how to use curator – sweety Apr 28 '16 at 11:54
-
Simply install it (check the link I shared) and then run the command I gave you above. – Val Apr 28 '16 at 11:54
-
Thanks _@Val_, I got it. I will get back if I have any issues. – sweety Apr 28 '16 at 12:01
-
Can you suggest me, how many master nodes and data nodes, and replication is well enough for the production environment? @Val – sweety May 11 '16 at 10:18
-
It ultimately depends on your data and use cases. – Val May 11 '16 at 11:10