# Filter out objects with specific IDs

**URL:** <https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161>\
**Category:** Elasticsearch\
**Created:** [August 14, 2011, 8:25pm UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161 "2011-08-14T20:25:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Grebs](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@Christopher\_Grebs](https://discuss.elastic.co/u/Christopher_Grebs)\
**Post date:** [August 14, 2011, 8:25pm UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/1 "2011-08-14T20:25:47Z")

</div>

Hey there everyone!

I am trying to implement some ACL filter into my search queries and  
the simplest way to do that seems to be a filtered query with a script  
filter.

All my documents have a `forum_pk` field with the ID and I collect all  
forum ids a user has access to. To filter out forums a user does not  
has access to I came up with this: [https://gist.github.com/1145266](https://gist.github.com/1145266)

The problem is that this now filters all documents and none is  
returned, but there are documents with a forum\_pk different then the  
missing 8. In this query only forums with ID 8 should be filtered  
out.

I use the mvel scripting interface, but also tried python with no  
success.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Christopher\_Grebs](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@Christopher\_Grebs](https://discuss.elastic.co/u/Christopher_Grebs)\
**Post date:** [August 14, 2011, 9:04pm UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/2 "2011-08-14T21:04:01Z")

</div>

Okay, sorry everyone... I was dumb enough to forget the proper  
mapping. Now it works fine.

Sorry!

Regards,  
Christopher.

On Aug 14, 10:25 pm, Christopher Grebs [cgr...@googlemail.com](mailto:cgr...@googlemail.com) wrote:

> Hey there everyone!
> 
> I am trying to implement some ACL filter into my search queries and  
> the simplest way to do that seems to be a filtered query with a script  
> filter.
> 
> All my documents have a `forum_pk` field with the ID and I collect all  
> forum ids a user has access to. To filter out forums a user does not  
> has access to I came up with this:[gist:1145266 · GitHub](https://gist.github.com/1145266)
> 
> The problem is that this now filters all documents and none is  
> returned, but there are documents with a forum\_pk different then the  
> missing 8. In this query only forums with ID 8 should be filtered  
> out.
> 
> I use the mvel scripting interface, but also tried python with no  
> success.
> 
> What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 14, 2011, 10:46pm UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/3 "2011-08-14T22:46:38Z")

</div>

I suggest using terms filter for this, and not script, it will be faster and  
cacheable.

On Mon, Aug 15, 2011 at 12:04 AM, Christopher Grebs  
[cgrebs@googlemail.com](mailto:cgrebs@googlemail.com)wrote:

> Okay, sorry everyone... I was dumb enough to forget the proper  
> mapping. Now it works fine.
> 
> Sorry!
> 
> Regards,  
> Christopher.
> 
> On Aug 14, 10:25 pm, Christopher Grebs [cgr...@googlemail.com](mailto:cgr...@googlemail.com) wrote:
> 
> > Hey there everyone!
> > 
> > I am trying to implement some ACL filter into my search queries and  
> > the simplest way to do that seems to be a filtered query with a script  
> > filter.
> > 
> > All my documents have a `forum_pk` field with the ID and I collect all  
> > forum ids a user has access to. To filter out forums a user does not  
> > has access to I came up with this:[gist:1145266 · GitHub](https://gist.github.com/1145266)
> > 
> > The problem is that this now filters all documents and none is  
> > returned, but there are documents with a forum\_pk different then the  
> > missing 8. In this query only forums with ID 8 should be filtered  
> > out.
> > 
> > I use the mvel scripting interface, but also tried python with no  
> > success.
> > 
> > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Christopher\_Grebs](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@Christopher\_Grebs](https://discuss.elastic.co/u/Christopher_Grebs)\
**Post date:** [August 15, 2011, 4:44am UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/4 "2011-08-15T04:44:39Z")

</div>

Hey,

this is great this is indeed mus simpler and faster. Thanks! Now I  
just need to find out a way to filter out items with a index specific  
terms filter if I search over more indices, do you have any suggestion  
on this? Combining them with `and` or `or` does not seem to work  
properly.

Regards,  
Christopher.

On Mon, Aug 15, 2011 at 12:46 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> I suggest using terms filter for this, and not script, it will be faster and  
> cacheable.
> 
> On Mon, Aug 15, 2011 at 12:04 AM, Christopher Grebs [cgrebs@googlemail.com](mailto:cgrebs@googlemail.com)  
> wrote:
> 
> > Okay, sorry everyone... I was dumb enough to forget the proper  
> > mapping. Now it works fine.
> > 
> > Sorry!
> > 
> > Regards,  
> > Christopher.
> > 
> > On Aug 14, 10:25 pm, Christopher Grebs [cgr...@googlemail.com](mailto:cgr...@googlemail.com) wrote:
> > 
> > > Hey there everyone!
> > > 
> > > I am trying to implement some ACL filter into my search queries and  
> > > the simplest way to do that seems to be a filtered query with a script  
> > > filter.
> > > 
> > > All my documents have a `forum_pk` field with the ID and I collect all  
> > > forum ids a user has access to. To filter out forums a user does not  
> > > has access to I came up with this:[gist:1145266 · GitHub](https://gist.github.com/1145266)
> > > 
> > > The problem is that this now filters all documents and none is  
> > > returned, but there are documents with a forum\_pk different then the  
> > > missing 8. In this query only forums with ID 8 should be filtered  
> > > out.
> > > 
> > > I use the mvel scripting interface, but also tried python with no  
> > > success.
> > > 
> > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 15, 2011, 11:00am UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/5 "2011-08-15T11:00:15Z")

</div>

Do you mean there are different fields you need to filter on between  
indices? An or filter should work.

On Mon, Aug 15, 2011 at 7:44 AM, Christopher Grebs [cgrebs@googlemail.com](mailto:cgrebs@googlemail.com)wrote:

> Hey,
> 
> this is great this is indeed mus simpler and faster. Thanks! Now I  
> just need to find out a way to filter out items with a index specific  
> terms filter if I search over more indices, do you have any suggestion  
> on this? Combining them with `and` or `or` does not seem to work  
> properly.
> 
> Regards,  
> Christopher.
> 
> On Mon, Aug 15, 2011 at 12:46 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > I suggest using terms filter for this, and not script, it will be faster  
> > and  
> > cacheable.
> > 
> > On Mon, Aug 15, 2011 at 12:04 AM, Christopher Grebs \<  
> > [cgrebs@googlemail.com](mailto:cgrebs@googlemail.com)\>  
> > wrote:
> > 
> > > Okay, sorry everyone... I was dumb enough to forget the proper  
> > > mapping. Now it works fine.
> > > 
> > > Sorry!
> > > 
> > > Regards,  
> > > Christopher.
> > > 
> > > On Aug 14, 10:25 pm, Christopher Grebs [cgr...@googlemail.com](mailto:cgr...@googlemail.com) wrote:
> > > 
> > > > Hey there everyone!
> > > > 
> > > > I am trying to implement some ACL filter into my search queries and  
> > > > the simplest way to do that seems to be a filtered query with a script  
> > > > filter.
> > > > 
> > > > All my documents have a `forum_pk` field with the ID and I collect all  
> > > > forum ids a user has access to. To filter out forums a user does not  
> > > > has access to I came up with this:[gist:1145266 · GitHub](https://gist.github.com/1145266)
> > > > 
> > > > The problem is that this now filters all documents and none is  
> > > > returned, but there are documents with a forum\_pk different then the  
> > > > missing 8. In this query only forums with ID 8 should be filtered  
> > > > out.
> > > > 
> > > > I use the mvel scripting interface, but also tried python with no  
> > > > success.
> > > > 
> > > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Christopher\_Grebs](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@Christopher\_Grebs](https://discuss.elastic.co/u/Christopher_Grebs)\
**Post date:** [August 15, 2011, 11:21am UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/6 "2011-08-15T11:21:24Z")

</div>

Hey Shay,

yea, I just played along with various filters and just stumbled upon  
the `type` filter and this seems to be the one I was looking for. At  
least the results now look as I want them to be, with index specific  
acl checks.

Thanks so much!

Regards,  
Christopher.

On Mon, Aug 15, 2011 at 1:00 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Do you mean there are different fields you need to filter on between  
> indices? An or filter should work.
> 
> On Mon, Aug 15, 2011 at 7:44 AM, Christopher Grebs [cgrebs@googlemail.com](mailto:cgrebs@googlemail.com)  
> wrote:
> 
> > Hey,
> > 
> > this is great this is indeed mus simpler and faster. Thanks! Now I  
> > just need to find out a way to filter out items with a index specific  
> > terms filter if I search over more indices, do you have any suggestion  
> > on this? Combining them with `and` or `or` does not seem to work  
> > properly.
> > 
> > Regards,  
> > Christopher.
> > 
> > On Mon, Aug 15, 2011 at 12:46 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> > 
> > > I suggest using terms filter for this, and not script, it will be faster  
> > > and  
> > > cacheable.
> > > 
> > > On Mon, Aug 15, 2011 at 12:04 AM, Christopher Grebs  
> > > [cgrebs@googlemail.com](mailto:cgrebs@googlemail.com)  
> > > wrote:
> > > 
> > > > Okay, sorry everyone... I was dumb enough to forget the proper  
> > > > mapping. Now it works fine.
> > > > 
> > > > Sorry!
> > > > 
> > > > Regards,  
> > > > Christopher.
> > > > 
> > > > On Aug 14, 10:25 pm, Christopher Grebs [cgr...@googlemail.com](mailto:cgr...@googlemail.com) wrote:
> > > > 
> > > > > Hey there everyone!
> > > > > 
> > > > > I am trying to implement some ACL filter into my search queries and  
> > > > > the simplest way to do that seems to be a filtered query with a  
> > > > > script  
> > > > > filter.
> > > > > 
> > > > > All my documents have a `forum_pk` field with the ID and I collect  
> > > > > all  
> > > > > forum ids a user has access to. To filter out forums a user does not  
> > > > > has access to I came up with this:[gist:1145266 · GitHub](https://gist.github.com/1145266)
> > > > > 
> > > > > The problem is that this now filters all documents and none is  
> > > > > returned, but there are documents with a forum\_pk different then the  
> > > > > missing 8. In this query only forums with ID 8 should be filtered  
> > > > > out.
> > > > > 
> > > > > I use the mvel scripting interface, but also tried python with no  
> > > > > success.
> > > > > 
> > > > > What am I doing wrong?

---

<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, 3:56am UTC](https://discuss.elastic.co/t/filter-out-objects-with-specific-ids/5161/7 "2017-07-06T03:56:59Z")

</div>

Closed on July 6, 2017, 3:56am UTC


