# Automatically detect needed index?

**URL:** <https://discuss.elastic.co/t/automatically-detect-needed-index/71850>\
**Category:** Elasticsearch\
**Created:** [January 17, 2017, 11:11am UTC](https://discuss.elastic.co/t/automatically-detect-needed-index/71850 "2017-01-17T11:11:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asp](https://avatars.discourse-cdn.com/v4/letter/a/9fc348/32.png) [@asp](https://discuss.elastic.co/u/asp)\
**Post date:** [January 17, 2017, 11:11am UTC](https://discuss.elastic.co/t/automatically-detect-needed-index/71850/1 "2017-01-17T11:11:22Z")

</div>

Hi,

I am sending some queries against elasticsearch via curl, called from a batch job.  
We are having currently following index pattern: [logstash-]YYYY.MM.DD  
So we rotate once per day.

Is there a way that elasticsearch is detecting the needed indexes automatically without querying all available indexes?  
If I set logstash-\* as index, the result tells me, that all shards have been queried. Since I query only a timeframe, where I need at max 2 days = 2 indexes, I wanted to optimize.  
Is there any way to optimize it automatically, or do I need to calculate the queried days and set both indexes in the curl query?

Thanks, Andreas

---

<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:** [February 14, 2017, 11:11am UTC](https://discuss.elastic.co/t/automatically-detect-needed-index/71850/2 "2017-02-14T11:11:30Z")

</div>

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