# Storing efficient queries in percolator

**URL:** <https://discuss.elastic.co/t/storing-efficient-queries-in-percolator/32709>\
**Category:** Elasticsearch\
**Created:** [October 21, 2015, 5:48pm UTC](https://discuss.elastic.co/t/storing-efficient-queries-in-percolator/32709 "2015-10-21T17:48:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daverino](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@Daverino](https://discuss.elastic.co/u/Daverino)\
**Post date:** [October 21, 2015, 5:48pm UTC](https://discuss.elastic.co/t/storing-efficient-queries-in-percolator/32709/1 "2015-10-21T17:48:42Z")

</div>

I have a number of relatively complicated queries that I want to store in percolator, but they are strictly yes-no. Therefore, what I'd really like to do is use a filter, rather than a query. I can wrap filter in a filtered query and add that (sans query) but that seems clunky. Is there a way to simple add a filter to percolator? Or am I thinking about it wrong and I should always think of filters in context of a query?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 22, 2015, 1:37pm UTC](https://discuss.elastic.co/t/storing-efficient-queries-in-percolator/32709/2 "2015-10-22T13:37:26Z")

</div>

I haven't benchmarked it but I suspect query vs filter performance matters less for percolation scenarios.

In normal search, filters can wind up as large cached bitsets with a 1 or 0 yes/no for millions of documents in a mostly static index. Cache hit ratios are very high so very efficient.  
In a percolation scenario the index is a transient in-memory one with only one document (the document currently being percolated). The filter bitset produced would only be of length 1 and of zero re-use because the next run of the query will be on an entirely different index with different contents.

---

<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 5, 2017, 11:43pm UTC](https://discuss.elastic.co/t/storing-efficient-queries-in-percolator/32709/3 "2017-07-05T23:43:16Z")

</div>


