# Bool and And filter, which is faster?

**URL:** https://discuss.elastic.co/t/bool-and-and-filter-which-is-faster/20880
**Category:** Elasticsearch
**Created:** [November 21, 2014, 12:46am UTC](https://discuss.elastic.co/t/bool-and-and-filter-which-is-faster/20880 "2014-11-21T00:46:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![virgil](https://avatars.discourse-cdn.com/v4/letter/v/4af34b/32.png) [@virgil](https://discuss.elastic.co/u/virgil)
#### Post date: [November 21, 2014, 12:46am UTC](https://discuss.elastic.co/t/bool-and-and-filter-which-is-faster/20880/1 "2014-11-21T00:46:05Z")

</div>

In this  
article [http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/),  
it's saying bool is faster than add/or filters. But at that time it's  
elasticsearch 0.9.  
Is this still the truth?

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/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [November 21, 2014, 9:21am UTC](https://discuss.elastic.co/t/bool-and-and-filter-which-is-faster/20880/2 "2014-11-21T09:21:49Z")

</div>

Unfortunately, it depends on many factors, but basically elasticsearch 1.x  
is going to have faster bool filter if your sub filters are dense and can  
be efficiently loaded into bitsets (eg. range, term, terms filters), and  
the `and` filter is going to be faster if your sub filters are sparse, or  
if they need to be evaluated one-doc at a time (eg. geo or script filters).

We are not too happy with the fact that we can't make the right decisions  
in elasticsearch itself, but this is hopefully something that will be  
addressed in the next major version (there is already some progress towards  
that direction in the master branch).

On Fri, Nov 21, 2014 at 1:46 AM, Fei Xie [virgilxie@gmail.com](mailto:virgilxie@gmail.com) wrote:

> In this article  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/),  
> it's saying bool is faster than add/or filters. But at that time it's  
> elasticsearch 0.9.  
> Is this still the truth?
> 
> 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/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAL6Z4j4bnRfNEAZGoqdzbO9powfyYV6UmzDJthiG3spEVBpWMA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4bnRfNEAZGoqdzbO9powfyYV6UmzDJthiG3spEVBpWMA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![virgil](https://avatars.discourse-cdn.com/v4/letter/v/4af34b/32.png) [@virgil](https://discuss.elastic.co/u/virgil)
#### Post date: [November 21, 2014, 8:28pm UTC](https://discuss.elastic.co/t/bool-and-and-filter-which-is-faster/20880/3 "2014-11-21T20:28:04Z")

</div>

Thanks! Really appreciate your explanation.

On Friday, November 21, 2014 1:21:56 AM UTC-8, Adrien Grand wrote:

> Unfortunately, it depends on many factors, but basically elasticsearch 1.x  
> is going to have faster bool filter if your sub filters are dense and can  
> be efficiently loaded into bitsets (eg. range, term, terms filters), and  
> the `and` filter is going to be faster if your sub filters are sparse, or  
> if they need to be evaluated one-doc at a time (eg. geo or script filters).
> 
> We are not too happy with the fact that we can't make the right decisions  
> in elasticsearch itself, but this is hopefully something that will be  
> addressed in the next major version (there is already some progress towards  
> that direction in the master branch).
> 
> On Fri, Nov 21, 2014 at 1:46 AM, Fei Xie \<[virg...@gmail.com](mailto:virg...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > In this article  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/),  
> > it's saying bool is faster than add/or filters. But at that time it's  
> > elasticsearch 0.9.  
> > Is this still the truth?
> > 
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/69acf937-ea05-4bf0-b3a6-f469644f842d%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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/626bab4b-5f69-4d03-97ac-33b776338527%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/626bab4b-5f69-4d03-97ac-33b776338527%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, 12:48am UTC](https://discuss.elastic.co/t/bool-and-and-filter-which-is-faster/20880/4 "2017-07-06T00:48:23Z")

</div>


