# Get by ID appears to bypass Alias / Filter

**URL:** <https://discuss.elastic.co/t/get-by-id-appears-to-bypass-alias-filter/14222>\
**Category:** Elasticsearch\
**Created:** [November 1, 2013, 6:13pm UTC](https://discuss.elastic.co/t/get-by-id-appears-to-bypass-alias-filter/14222 "2013-11-01T18:13:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brent\_Gracey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brent_gracey/32/823_2.png) [@Brent\_Gracey](https://discuss.elastic.co/u/Brent_Gracey)\
**Post date:** [November 1, 2013, 6:13pm UTC](https://discuss.elastic.co/t/get-by-id-appears-to-bypass-alias-filter/14222/1 "2013-11-01T18:13:44Z")

</div>

Hi,

I have an Alias set up to filter on a field called owner

[http://localhost:9200/message/\_alias/\*](http://localhost:9200/message/_alias/*)

{"message":{"aliases":{"123":{"filter":{"term":{"owner":"123"}}}}}}

It appears that if I do a GET by ID on the alias, documents are returned,  
even if their owner field is not "123" - so the filter does not take effect.

Is this expected behaviour? If so, is there any way to enfore that the  
filter is applied to the GET by Id API?

Two test records are held, one owner is 123 the other is 7984

{  
\_index: message  
\_type: data  
\_id:\* pQc6hWe6Sz2Oagm-nAFN1w\*  
\_version: 1  
\_score: 1  
\_source: {  
_owner: 7894_  
type: email  
...  
}

{  
\_index: message  
\_type: data  
\_id: _kBbun94eTOSPz\_Aot3S3Mg_  
\_version: 1  
\_score: 1  
\_source: {  
_owner: 123_  
type: email  
}

Both [http://localhost:9200/123/data/](http://localhost:9200/123/data/)_pQc6hWe6Sz2Oagm-nAFN1w/_ and  
[http://localhost:9200/123/data\*/kBbun94eTOSPz\_Aot3S3Mg/](http://localhost:9200/123/data*/kBbun94eTOSPz_Aot3S3Mg/) \*return the  
respective records.  
A search has it results filtered by owner as expected.

Thanks  
Brent

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![javanna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javanna/32/4698_2.png) [@javanna](https://discuss.elastic.co/u/javanna)\
**Post date:** [November 4, 2013, 5:37pm UTC](https://discuss.elastic.co/t/get-by-id-appears-to-bypass-alias-filter/14222/2 "2013-11-04T17:37:45Z")

</div>

Hi,  
right, the alias filter is not currently taken into account by the get api.  
We already have an open issue for it  
too: [Get document API can specify an alias, but will return documents that are not part of that alias (as defined by the filter for that alias) · Issue #3861 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3861).  
As mentioned in the issue, the tricky bit is that a get operation is  
real-time, while a search operation is near real-time. Applying the filter  
would mean executing a search... which would lead to lose the real-time  
aspect of the get api.

On Friday, November 1, 2013 7:13:44 PM UTC+1, Brent Gracey wrote:

> Hi,
> 
> I have an Alias set up to filter on a field called owner
> 
> [http://localhost:9200/message/\_alias/](http://localhost:9200/message/_alias/)\*
> 
> {"message":{"aliases":{"123":{"filter":{"term":{"owner":"123"}}}}}}
> 
> It appears that if I do a GET by ID on the alias, documents are returned,  
> even if their owner field is not "123" - so the filter does not take effect.
> 
> Is this expected behaviour? If so, is there any way to enfore that the  
> filter is applied to the GET by Id API?
> 
> Two test records are held, one owner is 123 the other is 7984
> 
> {  
> \_index: message  
> \_type: data  
> \_id:\* pQc6hWe6Sz2Oagm-nAFN1w\*  
> \_version: 1  
> \_score: 1  
> \_source: {  
> _owner: 7894_  
> type: email  
> ...  
> }
> 
> {  
> \_index: message  
> \_type: data  
> \_id: _kBbun94eTOSPz\_Aot3S3Mg_  
> \_version: 1  
> \_score: 1  
> \_source: {  
> _owner: 123_  
> type: email  
> }
> 
> Both [http://localhost:9200/123/data/\*pQc6hWe6Sz2Oagm-nAFN1w/](http://localhost:9200/123/data/*pQc6hWe6Sz2Oagm-nAFN1w/)\* and  
> [http://localhost:9200/123/data\*/kBbun94eTOSPz\_Aot3S3Mg/](http://localhost:9200/123/data*/kBbun94eTOSPz_Aot3S3Mg/) \*return the  
> respective records.  
> A search has it results filtered by owner as expected.
> 
> Thanks  
> Brent

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Brent\_Gracey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/brent_gracey/32/823_2.png) [@Brent\_Gracey](https://discuss.elastic.co/u/Brent_Gracey)\
**Post date:** [November 5, 2013, 6:28pm UTC](https://discuss.elastic.co/t/get-by-id-appears-to-bypass-alias-filter/14222/3 "2013-11-05T18:28:14Z")

</div>

OK - thanks for confirming and pointing out the relevant ticket

Cheers

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:08am UTC](https://discuss.elastic.co/t/get-by-id-appears-to-bypass-alias-filter/14222/4 "2017-07-06T02:08:43Z")

</div>

Closed on July 6, 2017, 2:08am UTC


