# Searching in indices between 2 date ranges without creating aliases

**URL:** <https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342>\
**Category:** Elasticsearch\
**Created:** [October 28, 2018, 1:02pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342 "2018-10-28T13:02:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jac1241](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jac1241](https://discuss.elastic.co/u/jac1241)\
**Post date:** [October 28, 2018, 1:02pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/1 "2018-10-28T13:02:49Z")

</div>

Let's consider i indices with dates, example: _index1-26-10-2018_ , _index1-27-10-2018_ , _index1-28-10-2018_ . Is there any way to search on index name which will mean : from _index1-26-10-2018_ to _index1-28-10-2018_ .

I'ved looked into [date math index names](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/date-math-index-names.html) but this won't help in my case. I've also thought about regex but index names don't support anything but a wildcard.

Does anyone have an idea?

thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 29, 2018, 10:14am UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/2 "2018-10-29T10:14:41Z")

</div>

can you explain why date math is not working in your case? You are aware that you can specify custom formats, right?

You always have the option to just specify the three indices manually and separate by comma like `index1-26-10-2018,index1-27-10-2018,index1-28-10-2018`

Hope this helps!

---

<div class="post-metadata">

**Author:** ![jac1241](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jac1241](https://discuss.elastic.co/u/jac1241)\
**Post date:** [October 29, 2018, 11:52am UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/3 "2018-10-29T11:52:48Z")

</div>

Thanks for the reply.

I'm aware of specific formats, but i have daily indices and allowing search for a year back.  
So i'f i'll implement something that translates a range of a year to a daily index list i'll perform query with a 365 index names, and i'm trying to avoid this.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2018, 12:04pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/4 "2018-10-29T12:04:04Z")

</div>

Which version of Elasticsearch are you using? How come you have named your indices this way instead of the more common format with year followed by month and date, which is sortable and potentially easier to use with prefixes?

---

<div class="post-metadata">

**Author:** ![jac1241](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jac1241](https://discuss.elastic.co/u/jac1241)\
**Post date:** [October 29, 2018, 12:25pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/5 "2018-10-29T12:25:42Z")

</div>

@Christian_Dahlqvist thank you for the reply.

Lets assume i can change the index names.  
Is there any way i can search on a range of index names?

For example:  
search from 29.10.18 - 30.10.18 will translate to indices 29.10.2018,30.10.2018  
search from 29.10-18 - 29.19. **19** will be translated to 365 daily index names in the request.

I thought about using wildcards based on the differences between the 2 ranges, but thought about checking some more intuitive solution first.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 29, 2018, 12:42pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/6 "2018-10-29T12:42:23Z")

</div>

Which version of Elasticsearch are you using?

---

<div class="post-metadata">

**Author:** ![jac1241](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@jac1241](https://discuss.elastic.co/u/jac1241)\
**Post date:** [October 29, 2018, 1:06pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/7 "2018-10-29T13:06:37Z")

</div>

5.4.3

---

<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:** [November 26, 2018, 1:06pm UTC](https://discuss.elastic.co/t/searching-in-indices-between-2-date-ranges-without-creating-aliases/154342/8 "2018-11-26T13:06:37Z")

</div>

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