# Short-circuit in bool query?

**URL:** <https://discuss.elastic.co/t/short-circuit-in-bool-query/18693>\
**Category:** Elasticsearch\
**Created:** [July 16, 2014, 9:50am UTC](https://discuss.elastic.co/t/short-circuit-in-bool-query/18693 "2014-07-16T09:50:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![11153](https://avatars.discourse-cdn.com/v4/letter/1/e274bd/32.png) [@11153](https://discuss.elastic.co/u/11153)\
**Post date:** [July 16, 2014, 9:50am UTC](https://discuss.elastic.co/t/short-circuit-in-bool-query/18693/1 "2014-07-16T09:50:16Z")

</div>

Hello,

I would like to know if I send a bool query like

{

"bool": {

"must": [

{

"term": { "user" : "john" }

},

{

"term": { "age" : 19 }

}

]

}

}

is the 2nd query (i.e. "age":19 ) only executed on documents that matches  
the 1st query? If not, can I have the same effect using other query types?  
Thank you.

--  
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/e48e0d77-82f2-4660-8dd9-d3a5dacd1868%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e48e0d77-82f2-4660-8dd9-d3a5dacd1868%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![11153](https://avatars.discourse-cdn.com/v4/letter/1/e274bd/32.png) [@11153](https://discuss.elastic.co/u/11153)\
**Post date:** [July 16, 2014, 9:56am UTC](https://discuss.elastic.co/t/short-circuit-in-bool-query/18693/2 "2014-07-16T09:56:50Z")

</div>

+more description

What we concerned is the search performance. In our case, user may send a  
bool query containing 5 or more match\_phrase queries. If each match\_phrase  
executes independently, the search performance will be extremely slow. We  
would like to have a way to short-circuit this. Thank you.

--  
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/1b52723e-668a-420c-95eb-c27223665e60%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1b52723e-668a-420c-95eb-c27223665e60%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![David\_Smith\_2](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@David\_Smith\_2](https://discuss.elastic.co/u/David_Smith_2)\
**Post date:** [July 16, 2014, 2:11pm UTC](https://discuss.elastic.co/t/short-circuit-in-bool-query/18693/3 "2014-07-16T14:11:38Z")

</div>

I'm also interested in this. If there's a way to do this, it would be  
pretty cool.

--  
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/a0ebb9e2-7ae4-475c-ad9d-577ad22d9db3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a0ebb9e2-7ae4-475c-ad9d-577ad22d9db3%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:15am UTC](https://discuss.elastic.co/t/short-circuit-in-bool-query/18693/4 "2017-07-06T01:15:28Z")

</div>


