# Way to apply date range on date math indices

**URL:** <https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410>\
**Category:** Elasticsearch\
**Created:** [August 21, 2018, 2:40pm UTC](https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410 "2018-08-21T14:40:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Indrani](https://avatars.discourse-cdn.com/v4/letter/i/ce7236/32.png) [@Indrani](https://discuss.elastic.co/u/Indrani)\
**Post date:** [August 21, 2018, 2:40pm UTC](https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410/1 "2018-08-21T14:40:40Z")

</div>

Is there a way to query data from multiple date math indices by date range ?

I have only seen by giving comma separated date math indices for searching, If I have to search over a year, it is difficult keep all the indices over a year.

Please suggest how I can use date range for date math indices.

Thanks!

---

<div class="post-metadata">

**Author:** ![mikebd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikebd/32/33437_2.png) [@mikebd](https://discuss.elastic.co/u/mikebd)\
**Post date:** [August 22, 2018, 1:02am UTC](https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410/2 "2018-08-22T01:02:51Z")

</div>

Try this: [https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/date-math-index-names.html)

---

<div class="post-metadata">

**Author:** ![Indrani](https://avatars.discourse-cdn.com/v4/letter/i/ce7236/32.png) [@Indrani](https://discuss.elastic.co/u/Indrani)\
**Post date:** [August 22, 2018, 7:10am UTC](https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410/3 "2018-08-22T07:10:57Z")

</div>

using date math index we can only send comma separated indices, but for example I have to get data from 2018.1.1 to current date, It's not good idea to send each date from 2018.1.1 to current date.

---

<div class="post-metadata">

**Author:** ![mikebd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikebd/32/33437_2.png) [@mikebd](https://discuss.elastic.co/u/mikebd)\
**Post date:** [August 22, 2018, 3:31pm UTC](https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410/4 "2018-08-22T15:31:43Z")

</div>

You could create an index alias that covers the year and add all of those indexes to the alias, then query against the alias.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html)

---

<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:** [September 19, 2018, 3:31pm UTC](https://discuss.elastic.co/t/way-to-apply-date-range-on-date-math-indices/145410/5 "2018-09-19T15:31:58Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
