# How to filter search results using scriptFilter and mvel?

**URL:** <https://discuss.elastic.co/t/how-to-filter-search-results-using-scriptfilter-and-mvel/5763>\
**Category:** Elasticsearch\
**Created:** [November 3, 2011, 7:51pm UTC](https://discuss.elastic.co/t/how-to-filter-search-results-using-scriptfilter-and-mvel/5763 "2011-11-03T19:51:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [November 3, 2011, 7:51pm UTC](https://discuss.elastic.co/t/how-to-filter-search-results-using-scriptfilter-and-mvel/5763/1 "2011-11-03T19:51:12Z")

</div>

For the following gist: [https://gist.github.com/1337584](https://gist.github.com/1337584)

1. Am I correct that if the mvel script returns true, then the doc  
will be filtered from search results?

2. Do I have the correct syntax for referring to the param accessBit  
or do I need to wrap with something like param['accessBit']?

Thanks,  
Shane

---

<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:** [November 8, 2011, 2:54am UTC](https://discuss.elastic.co/t/how-to-filter-search-results-using-scriptfilter-and-mvel/5763/2 "2011-11-08T02:54:07Z")

</div>

On Thu, Nov 3, 2011 at 9:51 PM, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com)wrote:

> For the following gist: [gist:1337584 · GitHub](https://gist.github.com/1337584)
> 
> 1. Am I correct that if the mvel script returns true, then the doc  
> will be filtered from search results?

No, its the other way around. If the script returns "true", it will be  
included in the search results.

> 1. Do I have the correct syntax for referring to the param accessBit  
> or do I need to wrap with something like param['accessBit']?

No, just using accessBit is good enough.

> Thanks,  
> Shane

---

<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:49am UTC](https://discuss.elastic.co/t/how-to-filter-search-results-using-scriptfilter-and-mvel/5763/3 "2017-07-06T03:49:42Z")

</div>

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


