# Can we pass index as a range

**URL:** <https://discuss.elastic.co/t/can-we-pass-index-as-a-range/127271>\
**Category:** Elasticsearch\
**Tags:** rally\
**Created:** [April 9, 2018, 8:19am UTC](https://discuss.elastic.co/t/can-we-pass-index-as-a-range/127271 "2018-04-09T08:19:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [April 9, 2018, 8:19am UTC](https://discuss.elastic.co/t/can-we-pass-index-as-a-range/127271/1 "2018-04-09T08:19:19Z")

</div>

Hi ,

Here is the scenario.

I have following indexes

event-2017-12-31  
event-2018-01-01  
event-2018-01-02  
....  
....  
event-2018-01-31

I want to search the data between index range event-2017-12-31 - event-2018-01-10

Current I am using it like:

res = es.search(index='event\*', doc\_type='farm-event',)

In that case it looks all the indexes starting from event due to this it's little slow.

Is there any way I can use "range" as index value instead of using event\*

---

<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:** [April 9, 2018, 11:43am UTC](https://discuss.elastic.co/t/can-we-pass-index-as-a-range/127271/2 "2018-04-09T11:43:51Z")

</div>

There is no need to implement this in Python. You can just use Rally's `search` operation as is in your track. Also, Rally does nothing special here and you can just use the [multiple indices syntax](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/multi-index.html) of Elasticsearch, e.g.

```auto
index="event-2017-12-31,event-2018-01-0*,event-2017-01-10"

```

Using an index range is not possible but if you have some kind of timestamp in your data you can use a range query indeed as Elasticsearch rewrites your query anyway since 5.0 to only hit matching shards (see the blog post [Instant Aggregations](https://www.elastic.co/blog/instant-aggregations-rewriting-queries-for-fun-and-profit)).

---

<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:** [May 7, 2018, 11:43am UTC](https://discuss.elastic.co/t/can-we-pass-index-as-a-range/127271/3 "2018-05-07T11:43:57Z")

</div>

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