55

I am using Elasticsearch 5.2, and cannot see index creation time with http://localhost:9200/_cat/indices?v.

Just wonder what options will show index creation time for each of the indices.

dapangmao
  • 2,727
  • 3
  • 22
  • 18

1 Answers1

115

Have a look at the cat API : you can get the list of available parameters via http://localhost:9200/_cat/indices?help

To get the creation date of your indexes, you would use creation.date (or creation.date.string). For example, use

http://localhost:9200/_cat/indices?h=h,s,i,id,p,r,dc,dd,ss,creation.date.string

For full header names:

http://localhost:9200/_cat/indices?h=health,status,index,id,pri,rep,docs.count,docs.deleted,store.size,creation.date.string&v=
Marc
  • 13,011
  • 11
  • 78
  • 98
nikoshr
  • 32,926
  • 33
  • 91
  • 105
  • 2
    How can I sort the indexes by creation date? – Amiga500 Jun 16 '17 at 09:08
  • 19
    @VedranMaricevic For ES5, append `&s=creation.date`, something like `http://localhost:9200/_cat/indices?h=h,s,i,id,p,r,dc,dd,ss,creation.date.string&s=creation.date` – nikoshr Jun 16 '17 at 09:18
  • thanks for including the "help" endpoint. and the documentation that documents the help endpoint! if you just go to the cat indices API then there is no reference to a "help". – Trevor Boyd Smith Dec 18 '18 at 14:34
  • how to get this through python client? i tried below, getting lots of information `es.indices.get('*')` if I give search index directly, not getting createddate `es.indices.get('index_name')`. thanks. – anand babu Nov 15 '19 at 11:28
  • @anandbabu You should use `es.cat.indices`, not `es.indices.get`. In the python client, use keyword params "h" for headings and "s" for sort key. Like this: `print(es.cat.indices("index_name", h=("h","s","i","id","p","r","dc","dd","ss","creation.date.string"), s="creation.date"))`. The same also works with no index name, or "*". – KSR Dec 10 '19 at 23:02
  • Official ES and useful examples: [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-indices.html) and [here - old version](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/cat-indices.html) – Florin Vîrdol Aug 24 '21 at 14:27
  • `?help` is really useful! thank you :-) – asgs Oct 04 '21 at 08:54