# Possible to use Lucene filters?

**URL:** <https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469>\
**Category:** Elasticsearch\
**Created:** [September 28, 2011, 9:06am UTC](https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469 "2011-09-28T09:06:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sten\_Roger\_Sandvik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sten_roger_sandvik/32/2893_2.png) [@Sten\_Roger\_Sandvik](https://discuss.elastic.co/u/Sten_Roger_Sandvik)\
**Post date:** [September 28, 2011, 9:06am UTC](https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469/1 "2011-09-28T09:06:21Z")

</div>

Hi.

Is it possible to use Lucene filters inside ElasticSearch? Or somesort  
of bitset manipulation of the document result?

The reason I ask is that we want to restrict read access for certain  
users on certain documents. It can be alot of users and we do not want  
to index those rights if it's another possibility. Until now I have a  
custom search based on lucene, but want to use ElasticSearch instead.  
In our custom implementation we add a security filter that looks up in  
a table (or map) for each key and filter out those that will not be in  
the result.

Hope that someone has the answer 🙂

BR,  
Sten Roger

---

<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:** [September 28, 2011, 10:32am UTC](https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469/2 "2011-09-28T10:32:02Z")

</div>

You can plug your own custom filter parser. It needs to both be able to  
parse the representation of the filter, and then create it. See a sample for  
the simple term filter:  
[https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/TermFilterParser.java](https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/TermFilterParser.java)  
.

Once you have that, you can write a plugin that adds your own custom filter  
parser registered under a name by checking on IndexQueryParserModule  
instance, and using the addFilterParser on it.

On Wed, Sep 28, 2011 at 12:06 PM, Sten Roger [stenrs@gmail.com](mailto:stenrs@gmail.com) wrote:

> Hi.
> 
> Is it possible to use Lucene filters inside Elasticsearch? Or somesort  
> of bitset manipulation of the document result?
> 
> The reason I ask is that we want to restrict read access for certain  
> users on certain documents. It can be alot of users and we do not want  
> to index those rights if it's another possibility. Until now I have a  
> custom search based on lucene, but want to use Elasticsearch instead.  
> In our custom implementation we add a security filter that looks up in  
> a table (or map) for each key and filter out those that will not be in  
> the result.
> 
> Hope that someone has the answer 🙂
> 
> BR,  
> Sten Roger

---

<div class="post-metadata">

**Author:** ![Sten\_Roger\_Sandvik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sten_roger_sandvik/32/2893_2.png) [@Sten\_Roger\_Sandvik](https://discuss.elastic.co/u/Sten_Roger_Sandvik)\
**Post date:** [September 28, 2011, 10:44am UTC](https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469/3 "2011-09-28T10:44:58Z")

</div>

Thanks for a very fast response. This is what I am looking for.  
Thank's alot!

On Sep 28, 12:32 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> You can plug your own custom filter parser. It needs to both be able to  
> parse the representation of the filter, and then create it. See a sample for  
> the simple term filter:[https://github.com/elasticsearch/elasticsearch/blob/master/modules/el](https://github.com/elasticsearch/elasticsearch/blob/master/modules/el)...  
> .
> 
> Once you have that, you can write a plugin that adds your own custom filter  
> parser registered under a name by checking on IndexQueryParserModule  
> instance, and using the addFilterParser on it.
> 
> On Wed, Sep 28, 2011 at 12:06 PM, Sten Roger [ste...@gmail.com](mailto:ste...@gmail.com) wrote:
> 
> > Hi.
> 
> > Is it possible to use Lucene filters inside Elasticsearch? Or somesort  
> > of bitset manipulation of the document result?
> 
> > The reason I ask is that we want to restrict read access for certain  
> > users on certain documents. It can be alot of users and we do not want  
> > to index those rights if it's another possibility. Until now I have a  
> > custom search based on lucene, but want to use Elasticsearch instead.  
> > In our custom implementation we add a security filter that looks up in  
> > a table (or map) for each key and filter out those that will not be in  
> > the result.
> 
> > Hope that someone has the answer 🙂
> 
> > BR,  
> > Sten Roger

---

<div class="post-metadata">

**Author:** ![Drew\_J\_Sonne](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@Drew\_J\_Sonne](https://discuss.elastic.co/u/Drew_J_Sonne)\
**Post date:** [July 30, 2012, 12:41am UTC](https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469/4 "2012-07-30T00:41:56Z")

</div>

The mentioned URL is now here:  
[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/TermFilterParser.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/TermFilterParser.java)

On Wednesday, September 28, 2011 8:32:02 PM UTC+10, kimchy wrote:

> You can plug your own custom filter parser. It needs to both be able to  
> parse the representation of the filter, and then create it. See a sample  
> for the simple term filter:  
> [https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/TermFilterParser.java](https://github.com/elasticsearch/elasticsearch/blob/master/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/TermFilterParser.java)  
> .
> 
> Once you have that, you can write a plugin that adds your own custom  
> filter parser registered under a name by checking on IndexQueryParserModule  
> instance, and using the addFilterParser on it.
> 
> On Wed, Sep 28, 2011 at 12:06 PM, Sten Roger [stenrs@gmail.com](mailto:stenrs@gmail.com) wrote:
> 
> > Hi.
> > 
> > Is it possible to use Lucene filters inside Elasticsearch? Or somesort  
> > of bitset manipulation of the document result?
> > 
> > The reason I ask is that we want to restrict read access for certain  
> > users on certain documents. It can be alot of users and we do not want  
> > to index those rights if it's another possibility. Until now I have a  
> > custom search based on lucene, but want to use Elasticsearch instead.  
> > In our custom implementation we add a security filter that looks up in  
> > a table (or map) for each key and filter out those that will not be in  
> > the result.
> > 
> > Hope that someone has the answer 🙂
> > 
> > BR,  
> > Sten Roger

---

<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:18am UTC](https://discuss.elastic.co/t/possible-to-use-lucene-filters/5469/5 "2017-07-06T03:18:32Z")

</div>


