# Date math for index names - date range possible?

**URL:** <https://discuss.elastic.co/t/date-math-for-index-names-date-range-possible/55044>\
**Category:** Elasticsearch\
**Created:** [July 8, 2016, 11:40am UTC](https://discuss.elastic.co/t/date-math-for-index-names-date-range-possible/55044 "2016-07-08T11:40:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alienmind](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alienmind/32/10799_2.png) [@alienmind](https://discuss.elastic.co/u/alienmind)\
**Post date:** [July 8, 2016, 11:40am UTC](https://discuss.elastic.co/t/date-math-for-index-names-date-range-possible/55044/1 "2016-07-08T11:40:15Z")

</div>

EDIT: The question could be rephrased also as:

When working with date based indexes, Is it any better to provide the exact indexes for searching (potentially a huge list):  
GET /whatever-YYYYMM01,whatever-YYYYMM02,...

OR

GET /whatever-\*

- date range query

I've been assuming that it's better to provide the exact indexes, but the query string can be huge and exceed HTTP's maximum allowed length for GET

I was wondering if there's an easy way to perform an index pattern definition where the index name depends on the date, based on a date range (start\_date, end\_date)

I've been trying to fit some date math in the index names such as suggested here:

[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)

It looks very limited - I can do things such as:

`GET /<whatever-{now/d{YYYYMMdd|+12:00}}>/_search`

but apparently I cannot define a simple date range between two dates.

My indexes are named: whatever-YYYYMMDD

If i require to query over a year, I'm forced to do either:

1. GET /whatever-\* (might not be the best option as my retention policy is for three years)
2. Programatically expand the range to individual indexes names and do GET /whatever-YYYYMM01,whatever-YYYYMM02,... , YYYYMMXX =\> Fails as the GET string is longer than what supports HTTP
3. Do several searches iterating over several ranges (calculated)
4. Other options?

Any suggestion is appreciated

Thanks

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [July 14, 2016, 9:45am UTC](https://discuss.elastic.co/t/date-math-for-index-names-date-range-possible/55044/2 "2016-07-14T09:45:09Z")

</div>

Hi,  
would it be possible to use wildcards like `whatever-2016*` and `whatever-2015-12*`, `whatever-2015-11*` etc. it seems like that would reduce the number of expressions you have to provide, although you do have a bit of logic in your application to build that.

Does that make sense?

---

<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:35pm UTC](https://discuss.elastic.co/t/date-math-for-index-names-date-range-possible/55044/3 "2017-07-05T22:35:44Z")

</div>


