Are shards skipped when a range query does not create hits

In my templated mapping, I use a sort.field on a datetime field. That datetime field thus contains increasing values for the rows inserted during the day. I rollover daily, and do a force merge on older indices.

I want to know if doing a range query on the datetime will know it can skip some indices based on the min and max value of the datetime field. I.e. not even having to talk to the shard(s).

I found nothing in the doc or discussion forums.

If I do a "profile":true in Kibana's dev tools, I see that there is definitely a difference between matching and non-matching shards (ConstantScoreQuery vs MatchNoDocsQuery). But that doesn't tell me where the optimization took place, that is, if shards had to be contacted to reach that conclusion, or if there is a list of the min/max values for all shards/indices that allows eager elimination of shards.

Thank you for any feedback


Yes, there is a pre-flight search phase called the can match search phase that removes all shards from a search request that a query can not match (e.g., if a range query does not overlap with the range of values for a shard). This feature exists since 5.6.


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