# Does the pitfall of the and filter apply to the terms filter, too?

**URL:** https://discuss.elastic.co/t/does-the-pitfall-of-the-and-filter-apply-to-the-terms-filter-too/19644
**Category:** Elasticsearch
**Created:** [September 5, 2014, 1:30pm UTC](https://discuss.elastic.co/t/does-the-pitfall-of-the-and-filter-apply-to-the-terms-filter-too/19644 "2014-09-05T13:30:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Andre\_Hansel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre_hansel/32/934_2.png) [@Andre\_Hansel](https://discuss.elastic.co/u/Andre_Hansel)
#### Post date: [September 5, 2014, 1:30pm UTC](https://discuss.elastic.co/t/does-the-pitfall-of-the-and-filter-apply-to-the-terms-filter-too/19644/1 "2014-09-05T13:30:35Z")

</div>

This question is about querying documents from the whole index using a  
"filtered" query (and not about filtering further down some query results).

According  
to [http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/](http://www.elasticsearch.org/blog/all-about-elasticsearch-filter-bitsets/)  
the "and" filter is a very bad choice to query from all documents, because  
it does not use a BitSet but just walks through all documents and checks  
the conditions.

Does this also apply to a terms filter with "execution": "and" and  
"execution": "or", too?

If yes, that would mean if I want the terms to be AND-ed, I should use  
"execution": "bool" instead of "execution": "and". If I want the terms to  
be OR-ed but cached separetely, I'm out of luck with the "terms" filter,  
right?

--  
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/a0d9058b-9bb2-4489-bcab-6658a77e85f8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0d9058b-9bb2-4489-bcab-6658a77e85f8%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:04am UTC](https://discuss.elastic.co/t/does-the-pitfall-of-the-and-filter-apply-to-the-terms-filter-too/19644/2 "2017-07-06T01:04:07Z")

</div>


