# Do I need to wrap a MissingField Filter inside a bool filter?

**URL:** <https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879>\
**Category:** Elasticsearch\
**Created:** [February 18, 2014, 7:19pm UTC](https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879 "2014-02-18T19:19:56Z")\
**Posts on this page:** 5\
**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, 7:19pm UTC](https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879/1 "2014-02-18T19:19:56Z")

</div>

Reading

> **[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...

it looks like the bool filter is the way to go when using a certain  
combination of filters.

But what if it's only one filter, which is cached, and presumably a  
bitset filter?

I'm talking about the "MissingField" filter.

should this

{  
"bool": {  
"must": {  
{ "missing": {"field": "out\_of\_stock", "existence": True}}  
}  
}  
}

performs better than

{  
"missing": {  
"field": "out\_of\_stock",  
"existence": True  
}  
}

## I just got a bit confused with the blog post. I think they both should perform the same.

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/CAKNaH0UwiXt%2BKD%2BBc3jNJWBCiYx83851qj%3DwtHM9geQKs6XzNg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKNaH0UwiXt%2BKD%2BBc3jNJWBCiYx83851qj%3DwtHM9geQKs6XzNg%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:** ![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, 7:24pm UTC](https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879/2 "2014-02-18T19:24:29Z")

</div>

The missing filter should be cached by default if that's what you wanted to  
know:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html)

So no need to bool it if that's what you're worried about.

--  
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/43f2943f-4df6-4ca0-a9a4-eab283ab0c9c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/43f2943f-4df6-4ca0-a9a4-eab283ab0c9c%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 19, 2014, 9:47pm UTC](https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879/3 "2014-02-19T21:47:36Z")

</div>

just for the purpose of clarification.

the "bitset" feature is equivalent to the "cacheable" feature. the AND/OR  
filters can't cache its results since they always have to compare to other  
docs , but if a filter can be "translated" into a bitset, then it can be  
"saved" for future references, and that doc hasn't to be examined again in  
order to see if complies with the filter, but a single look at its bitset  
records should be enough.

??

On Tuesday, February 18, 2014 2:24:29 PM UTC-5, Binh Ly wrote:

> The missing filter should be cached by default if that's what you wanted  
> to know:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html)
> 
> So no need to bool it if that's what you're worried about.

--  
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/4d43eaed-5534-4842-a3f1-73a7d648bc1d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4d43eaed-5534-4842-a3f1-73a7d648bc1d%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:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 19, 2014, 10:52pm UTC](https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879/4 "2014-02-19T22:52:17Z")

</div>

Indeed there is no need to wrap a missing filter inside of a bool filter  
and execution performance would be exactly the same.

What you just said about filters is correct.

On Wed, Feb 19, 2014 at 10:47 PM, JoeZ99 [jzarate@gmail.com](mailto:jzarate@gmail.com) wrote:

> just for the purpose of clarification.
> 
> the "bitset" feature is equivalent to the "cacheable" feature. the AND/OR  
> filters can't cache its results since they always have to compare to other  
> docs , but if a filter can be "translated" into a bitset, then it can be  
> "saved" for future references, and that doc hasn't to be examined again in  
> order to see if complies with the filter, but a single look at its bitset  
> records should be enough.
> 
> ??
> 
> On Tuesday, February 18, 2014 2:24:29 PM UTC-5, Binh Ly wrote:
> 
> > The missing filter should be cached by default if that's what you wanted  
> > to know:
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/query-dsl-missing-filter.html
> > 
> > So no need to bool it if that's what you're worried about.
> 
> --  
> 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/4d43eaed-5534-4842-a3f1-73a7d648bc1d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4d43eaed-5534-4842-a3f1-73a7d648bc1d%40googlegroups.com)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Adrien Grand

--  
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/CAL6Z4j6M8joqsVLFq-Oc5W%3DhXwvMQjVo37CGeFEpaC-KCLuuVA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j6M8joqsVLFq-Oc5W%3DhXwvMQjVo37CGeFEpaC-KCLuuVA%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:48am UTC](https://discuss.elastic.co/t/do-i-need-to-wrap-a-missingfield-filter-inside-a-bool-filter/15879/5 "2017-07-06T01:48:57Z")

</div>


