# Fetching Documents with alias

**URL:** <https://discuss.elastic.co/t/fetching-documents-with-alias/307285>\
**Category:** Elasticsearch\
**Created:** [June 15, 2022, 1:52pm UTC](https://discuss.elastic.co/t/fetching-documents-with-alias/307285 "2022-06-15T13:52:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skeldren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skeldren/32/100025_2.png) [@Skeldren](https://discuss.elastic.co/u/Skeldren)\
**Post date:** [June 15, 2022, 1:52pm UTC](https://discuss.elastic.co/t/fetching-documents-with-alias/307285/1 "2022-06-15T13:52:20Z")

</div>

Hey all 👋

I have a question regarding alias.

Basically was performing some tests to check how it worked.  
I created two Alias for the same Index with different routing keys and filters.  
Let's say the Index is called `accounts` and the Alias are `account1` and `account2`.  
account1 will filter the account of a given person and account2 of another person.

If i perform a search using one of the alias, i only get documents where it matches the filter (as it is suppose to happen).  
`https://localhost:9200/account1/_search`

But if i perform a fetch of a document belonging to the other alias, im able to get it.  
`https://localhost:9200/account1/_doc/<doc-belloging-to-account-2>`

In other words the filter is not applied. Alias is just being used for its routing key.  
As the query would be simply this  
`https://localhost:9200/accounts/_doc/<doc-belloging-to-account-2>?routing=account1`

This seems to be the behavior by design, but just wanted to make sure.  
Would appreciate if someone could confirm this is the normal behavior.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 21, 2022, 1:56am UTC](https://discuss.elastic.co/t/fetching-documents-with-alias/307285/2 "2022-06-21T01:56:24Z")

</div>

It'd be useful if you could share the details of the aliases you setup.

---

<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:** [July 19, 2022, 1:57am UTC](https://discuss.elastic.co/t/fetching-documents-with-alias/307285/3 "2022-07-19T01:57:05Z")

</div>

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