Searching Indexes based on Index Creation date

Hi,
I have requirement of querying the ElasticSearch Indexes which are created prior to a given date. By using the Sense Plugin (Chrome Browser) for ElasticSearch , i am able to see the settings of the indexes which is having the field index."creation_date". Can i use this field to Query the ES to return the indexes by creation date? I have multiple indexes starting with "testagent-"

the Settings of my index look like

Please let me know whether this is possible or not.

Thanks and Best Regards,
RK

Hi @ramkchirra,

you cannot use the index creation date in queries. Your problem is typically solved by time-based indices (one index per day / month / year depending on the use case). You can then reference multiple indices in your query.

You could also combine this approach with a timestamp that you store in each document. For the coarse-grained selection you use indices and for the fine-grained selection you use the timestamp in the document.

Say, you want to retrieve all documents before March 5 2010 and you have one index for each year, then you can query all indices up until 2010: /+testagent-200*,+testagent-2010. For the fine-grained selection you restrict to all dates before March 5 2010 in the query.

However, I'd start with the easier approach of querying all indices (i.e. /testagent-*) and just relying on the timestamp restriction in the query. If that is too slow you can always start to optimize.

Daniel

1 Like

Thanks for the reply !! :slight_smile:

You're welcome. I hope it helps you. :slight_smile: