# Searching Indexes based on Index Creation date

**URL:** https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684
**Category:** Elasticsearch
**Created:** [June 14, 2016, 4:00am UTC](https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684 "2016-06-14T04:00:26Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ramkchirra](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramkchirra](https://discuss.elastic.co/u/ramkchirra)
#### Post date: [June 14, 2016, 4:00am UTC](https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684/1 "2016-06-14T04:00:26Z")

</div>

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

![](https://us1.discourse-cdn.com/elastic/original/2X/b/be4bb18aa4af4398168aa484bd6a2dbad054b73f.png)

Please let me know whether this is possible or not.

Thanks and Best Regards,  
RK

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [June 14, 2016, 8:28am UTC](https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684/2 "2016-06-14T08:28:09Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html).

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

---

<div class="post-metadata">

### Author: ![ramkchirra](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@ramkchirra](https://discuss.elastic.co/u/ramkchirra)
#### Post date: [June 14, 2016, 9:23am UTC](https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684/3 "2016-06-14T09:23:59Z")

</div>

Thanks for the reply !! 🙂

---

<div class="post-metadata">

### Author: ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)
#### Post date: [June 14, 2016, 9:31am UTC](https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684/4 "2016-06-14T09:31:26Z")

</div>

You're welcome. I hope it helps you. 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 5, 2017, 10:44pm UTC](https://discuss.elastic.co/t/searching-indexes-based-on-index-creation-date/52684/5 "2017-07-05T22:44:00Z")

</div>


