# Filtered query with wildcard index names vs Querying on aliases

**URL:** <https://discuss.elastic.co/t/filtered-query-with-wildcard-index-names-vs-querying-on-aliases/55514>\
**Category:** Elasticsearch\
**Created:** [July 14, 2016, 12:19pm UTC](https://discuss.elastic.co/t/filtered-query-with-wildcard-index-names-vs-querying-on-aliases/55514 "2016-07-14T12:19:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sruthi](https://avatars.discourse-cdn.com/v4/letter/s/ee7513/32.png) [@sruthi](https://discuss.elastic.co/u/sruthi)\
**Post date:** [July 14, 2016, 12:19pm UTC](https://discuss.elastic.co/t/filtered-query-with-wildcard-index-names-vs-querying-on-aliases/55514/1 "2016-07-14T12:19:24Z")

</div>

Scenario:  
You have different indexes per day such as D1, D2, D3, .... .D10.  
Now if you need data from only D1 and D2, which is best approach?

1. Query with index with wildcard eg:D\* and filter with date
2. Create an alias for D1 and D2 and query on that

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 14, 2016, 12:22pm UTC](https://discuss.elastic.co/t/filtered-query-with-wildcard-index-names-vs-querying-on-aliases/55514/2 "2016-07-14T12:22:42Z")

</div>

Option 2, or a new option 3:

Query just the two indices and filter with date: `GET /D1,D2/my_type/_search`.

Option 1 will technically work, but it will do extra computation that isn't needed. Because the wildcard will hit all indices, the search will be broadcast to all the involved shards (even if they aren't D1 or D2). So if you can limit the search to just D1 + D2, either via an alias or by specifying them manually, you'll have better performance 🙂

---

<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/filtered-query-with-wildcard-index-names-vs-querying-on-aliases/55514/3 "2017-07-05T22:35:35Z")

</div>


