# Filtered Alias not working on Inner Hits

**URL:** <https://discuss.elastic.co/t/filtered-alias-not-working-on-inner-hits/221344>\
**Category:** Elasticsearch\
**Created:** [February 28, 2020, 12:57am UTC](https://discuss.elastic.co/t/filtered-alias-not-working-on-inner-hits/221344 "2020-02-28T00:57:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![acuitymd](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@acuitymd](https://discuss.elastic.co/u/acuitymd)\
**Post date:** [February 28, 2020, 12:57am UTC](https://discuss.elastic.co/t/filtered-alias-not-working-on-inner-hits/221344/1 "2020-02-28T00:57:27Z")

</div>

Hi,

I have a multitenant architecture where there is a large set of "master" data between each tenant, then smaller pieces of tenant-specific data.

To query only for a specific tenant, I have a filtered alias where I'm filtering out child documents based on a field only found in child documents. The filter includes all "parent" documents and only the relevant "child" documents for that alias.

When I run a query for child documents on the alias, the results are correctly filtered. When I query for a parent document, and then use "inner\_hits", all child documents are returned, not just the ones visible to that alias. Thus, "inner\_hits" results are breaking out of the alias filter.

Question #1: Why doesn't this work?

If the answer is "alias filters don't apply to inner-hits", the only other options I see to secure this properly is:

- Document-level permissions for a role per-tenant
  - Unfortunately, this means disabling the query cache, which is a non-starter as I have an aggregation-heavy workload that needs caching to be usable.

- An index per-tenant
  - If each index has the "master" data, it would be a massive duplication that I want to avoid at any cost.
  - If each index is separate from the "master" index, I would need to do all joins on the application side.

Question #2: Can someone help here? If the filtered alias doesn't work on the "inner\_hits", there is no scalable way to do this without either

- Re-writing every query to be tenant-specific
- Resorting to doing application-side joins.
- Duplicating all "master" data
- Disabling caching

Thanks

---

<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:** [March 27, 2020, 12:57am UTC](https://discuss.elastic.co/t/filtered-alias-not-working-on-inner-hits/221344/2 "2020-03-27T00:57:40Z")

</div>

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