# BitSet Filters in ES/Lucene

**URL:** <https://discuss.elastic.co/t/bitset-filters-in-es-lucene/19221>\
**Category:** Elasticsearch\
**Created:** [August 12, 2014, 7:44am UTC](https://discuss.elastic.co/t/bitset-filters-in-es-lucene/19221 "2014-08-12T07:44:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticSearch\_Users\_](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@ElasticSearch\_Users\_](https://discuss.elastic.co/u/ElasticSearch_Users_)\
**Post date:** [August 12, 2014, 7:44am UTC](https://discuss.elastic.co/t/bitset-filters-in-es-lucene/19221/1 "2014-08-12T07:44:45Z")

</div>

Hi,  
I have looked at TermsLookupFilter and it is a good approach to cache  
frequently used filters. However, even if I write a custom filter plugin, I  
cannot use a BitSet to hold any sort of document identifier. Even the \_uid  
field is converted into a TermFilter.

Assume a scenario where I need to tag millions of documents with a tag like  
"Finance", "IT", "Legal", etc.

Unless, I can cache these filters in memory, the cost of constructing this  
filter at run time per query is not practical. If I could map the documents  
to a numeric long identifier and put them in a BitMap, I could then cache  
them because the size reduces drastically. However, I cannot use this  
numeric long identifier in ES/Lucene filters, either Custom Filter Plugin  
or Terms Lookup Filter. Is there any way?

I read about possible solutions in ES and found this link:  
[http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/).

Please help with this scenario. Thanks,

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d2a12986-220b-44c8-ac8f-a836de692c16%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d2a12986-220b-44c8-ac8f-a836de692c16%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:09am UTC](https://discuss.elastic.co/t/bitset-filters-in-es-lucene/19221/2 "2017-07-06T01:09:20Z")

</div>


