# How do inner hits work inside filtered aliases?

**URL:** <https://discuss.elastic.co/t/how-do-inner-hits-work-inside-filtered-aliases/163630>\
**Category:** Elasticsearch\
**Created:** [January 9, 2019, 11:04pm UTC](https://discuss.elastic.co/t/how-do-inner-hits-work-inside-filtered-aliases/163630 "2019-01-09T23:04:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![loren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/loren/32/44942_2.png) [@loren](https://discuss.elastic.co/u/loren)\
**Post date:** [January 9, 2019, 11:04pm UTC](https://discuss.elastic.co/t/how-do-inner-hits-work-inside-filtered-aliases/163630/1 "2019-01-09T23:04:32Z")

</div>

I want to create a filtered alias that contains a nested query with inner\_hits. I'd like to then run a more-specific nested query with inner\_hits against that filtered alias.

The inner hits from the filtered alias seem to get clobbered by the inner hits of the top-level query, and it has me wondering what the behavior is even supposed to be here.

Inner hits aside, when ES runs a filtered query on top of a filtered alias, how is that handled internally? Part of me thinks the alias is evaluated to return a set of document IDs, and then the top-level query is scoped to that set. Another part of me thinks they become two parts of a single bool query. Can anyone shed some light on this?

---

<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 6, 2019, 11:16pm UTC](https://discuss.elastic.co/t/how-do-inner-hits-work-inside-filtered-aliases/163630/2 "2019-02-06T23:16:20Z")

</div>

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