# The fastest filter under the sun?

**URL:** <https://discuss.elastic.co/t/the-fastest-filter-under-the-sun/15863>\
**Category:** Elasticsearch\
**Created:** [February 18, 2014, 1:53am UTC](https://discuss.elastic.co/t/the-fastest-filter-under-the-sun/15863 "2014-02-18T01:53:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon44344346](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@anon44344346](https://discuss.elastic.co/u/anon44344346)\
**Post date:** [February 18, 2014, 1:53am UTC](https://discuss.elastic.co/t/the-fastest-filter-under-the-sun/15863/1 "2014-02-18T01:53:00Z")

</div>

which is the fastest possible filter I could use to exclude documents from  
a search, provided that I have control of what fields those documents have?

in an ecommerce search engine, we used to not to index products that were  
"out of stock". however, if for some reason the ecommerce owner wants to  
show the "out of stock" products, she has to reindex them again.

following a tip from Igor Motov in another thread, I'm considering adding  
some "out\_of\_stock" field to every item, let them all be indexed, and use a  
filtered alias.

since I have control on the field I'm using for filtering, I figured I  
could use the one that allows me "the fastest filter under the sun".

I've assumed that would be the "missing field" filter, with  
"existence:True". i.e. only the documents that don't have the  
"out\_of\_stock" field pass the filter (I don't mind the field's value)

Am I right? is this the fastest/more performant filter I can use?

--  
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/ffae84ea-957c-4ecf-b5f1-9a1456437860%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ffae84ea-957c-4ecf-b5f1-9a1456437860%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 18, 2014, 6:45pm UTC](https://discuss.elastic.co/t/the-fastest-filter-under-the-sun/15863/2 "2014-02-18T18:45:44Z")

</div>

I wouldn't worry too much about this. Once the filter is cached, they  
should all behave about the same. What should matter to you is if the  
filter is cached or not. This should give you an idea of how to decide what  
filters to use:

> **[All About Elasticsearch Filter BitSets
	  	 | Elastic](https://www.elastic.co/blog/all-about-elasticsearch-filter-bitsets)**
>
> WARNING: This article contains outdated information. We no longer recommend taking its advice. When building queries in Elasticsearch, you’ll often find yourself composing sets of filters. Say you nee...

--  
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/930df8cc-c955-44e2-b4bb-fd6f75603b76%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/930df8cc-c955-44e2-b4bb-fd6f75603b76%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![anon44344346](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@anon44344346](https://discuss.elastic.co/u/anon44344346)\
**Post date:** [February 18, 2014, 7:20pm UTC](https://discuss.elastic.co/t/the-fastest-filter-under-the-sun/15863/3 "2014-02-18T19:20:58Z")

</div>

txs. binh. I have a new concern now, though, which is if, in the light  
of the blog post you mentioned, I should wrap my only "missing" filter  
inside a "bool" filter.

On Tue, Feb 18, 2014 at 1:45 PM, Binh Ly [binh@hibalo.com](mailto:binh@hibalo.com) wrote:

> I wouldn't worry too much about this. Once the filter is cached, they should  
> all behave about the same. What should matter to you is if the filter is  
> cached or not. This should give you an idea of how to decide what filters to  
> use:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/)
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/rZRGyK1Od8I/unsubscribe](https://groups.google.com/d/topic/elasticsearch/rZRGyK1Od8I/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/930df8cc-c955-44e2-b4bb-fd6f75603b76%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/930df8cc-c955-44e2-b4bb-fd6f75603b76%40googlegroups.com).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
uh, oh.

--  
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/CAKNaH0X7fJgJdnzs3M3zQ%2Bg9wRHkLq4k%2B2cBA4RgBGfMQk%2By4w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKNaH0X7fJgJdnzs3M3zQ%2Bg9wRHkLq4k%2B2cBA4RgBGfMQk%2By4w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:49am UTC](https://discuss.elastic.co/t/the-fastest-filter-under-the-sun/15863/4 "2017-07-06T01:49:19Z")

</div>


