# Automatic skipping of indexes / shards for date-based indexing and index sorting

**URL:** <https://discuss.elastic.co/t/automatic-skipping-of-indexes-shards-for-date-based-indexing-and-index-sorting/317399>\
**Category:** Elasticsearch\
**Created:** [October 25, 2022, 11:20am UTC](https://discuss.elastic.co/t/automatic-skipping-of-indexes-shards-for-date-based-indexing-and-index-sorting/317399 "2022-10-25T11:20:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jojo23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jojo23/32/72498_2.png) [@jojo23](https://discuss.elastic.co/u/jojo23)\
**Post date:** [October 25, 2022, 11:20am UTC](https://discuss.elastic.co/t/automatic-skipping-of-indexes-shards-for-date-based-indexing-and-index-sorting/317399/1 "2022-10-25T11:20:15Z")

</div>

I run an Elasticsearch cluster with dozens of time-based monthly indexes and 240+ shards. Query performance is always a priority, so I have been wondering if there are ways to improve which indexes / shards are actually queried. I already tried looking for documentation and Github tickets to no avail.

Specifically, this is my situation:

- The indexes use index sorting, by date:desc,key:asc.
- All queries only ever sort by those sort keys as well.
- All queries are run in filter mode using the query string query.
- All queries have a track\_total\_hits of 10000.
- Some queries also query for the date (e.g. date:\>now-1h)

Whenever I run a query it always seems to query all 240+ shards, and there are never skipped shards in the result. I was hoping for two things:

- Non-matching indexes / shards should be skipped according to a date filter in the query string
- Older indexes / shards should not be queried if the query has already reached 10000 results from the most recent monthly index.

I hope this question makes sense. I've tried playing with the max\_concurrent\_shard\_requests and pre\_filter\_shard\_size parameters to no avail.

---

<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 25, 2022, 11:33am UTC](https://discuss.elastic.co/t/automatic-skipping-of-indexes-shards-for-date-based-indexing-and-index-sorting/317399/2 "2022-10-25T11:33:12Z")

</div>

Which version of Elasticsearch are you using?

---

<div class="post-metadata">

**Author:** ![jojo23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jojo23/32/72498_2.png) [@jojo23](https://discuss.elastic.co/u/jojo23)\
**Post date:** [October 25, 2022, 11:37am UTC](https://discuss.elastic.co/t/automatic-skipping-of-indexes-shards-for-date-based-indexing-and-index-sorting/317399/3 "2022-10-25T11:37:45Z")

</div>

Version 8.4.2

---

<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 22, 2022, 11:37am UTC](https://discuss.elastic.co/t/automatic-skipping-of-indexes-shards-for-date-based-indexing-and-index-sorting/317399/4 "2022-11-22T11:37:49Z")

</div>

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