# CanMatch search phase and AliasFilter

**URL:** <https://discuss.elastic.co/t/canmatch-search-phase-and-aliasfilter/227515>\
**Category:** Elasticsearch\
**Created:** [April 10, 2020, 2:10pm UTC](https://discuss.elastic.co/t/canmatch-search-phase-and-aliasfilter/227515 "2020-04-10T14:10:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yfful](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yfful/32/88024_2.png) [@yfful](https://discuss.elastic.co/u/yfful)\
**Post date:** [April 10, 2020, 2:10pm UTC](https://discuss.elastic.co/t/canmatch-search-phase-and-aliasfilter/227515/1 "2020-04-10T14:10:54Z")

</div>

Hi,

If an aliased index contains a filter, the `SearchService#canMatch` method would rewrite it. However, that method doesn't check if the alias filter got rewritten to a `match_none` which would indicate that the shard could be skipped.  
Can you clarify why the alias filter is not taken into account by `canMatch` ?

Thanks

> <https://github.com/elastic/elasticsearch/blob/f7809dd096f50b345bf49914702af80f0ac081d4/server/src/main/java/org/elasticsearch/search/SearchService.java#L1112>

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [April 10, 2020, 3:19pm UTC](https://discuss.elastic.co/t/canmatch-search-phase-and-aliasfilter/227515/2 "2020-04-10T15:19:45Z")

</div>

It's not implemented but this is a good idea. I guess that you're using a range query in the alias filter ? I don't see any reason why we wouldn't do it so could you please open an issue in the public github ? If you're interested you can also open a pull request directly since the change should be straightforward.

---

<div class="post-metadata">

**Author:** ![yfful](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yfful/32/88024_2.png) [@yfful](https://discuss.elastic.co/u/yfful)\
**Post date:** [April 10, 2020, 9:39pm UTC](https://discuss.elastic.co/t/canmatch-search-phase-and-aliasfilter/227515/3 "2020-04-10T21:39:00Z")

</div>

@jimczi This is the related issue [https://github.com/elastic/elasticsearch/issues/55090](https://github.com/elastic/elasticsearch/issues/55090)

---

<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 8, 2020, 9:39pm UTC](https://discuss.elastic.co/t/canmatch-search-phase-and-aliasfilter/227515/4 "2020-05-08T21:39:02Z")

</div>

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