# Bool Query Execution Order

**URL:** <https://discuss.elastic.co/t/bool-query-execution-order/122435>\
**Category:** Elasticsearch\
**Created:** [March 5, 2018, 4:05am UTC](https://discuss.elastic.co/t/bool-query-execution-order/122435 "2018-03-05T04:05:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![panda2004](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/panda2004/32/19473_2.png) [@panda2004](https://discuss.elastic.co/u/panda2004)\
**Post date:** [March 5, 2018, 4:05am UTC](https://discuss.elastic.co/t/bool-query-execution-order/122435/1 "2018-03-05T04:05:59Z")

</div>

Do you belive ElasticSearch will try to search the documents according to the right order in the following query?

I know from this [post](https://www.elastic.co/blog/elasticsearch-query-execution-order) that Elasticsearch has its own mechanism for execution based on statistics, and therefore might change the order of execution.

The reason I ask about it, is becuase I want to know wether using a manipulated `maxReviewDate` field will boost performance (as you can see, I run this query on many indices). This field is store in the parent docs and maintaied for its nested docs. It's known that nested queries are slower than regular non-nested queries, and it would be nice to know that the nested query will run only when it has to run.

```
GET Products_January, Products_February, Products_March / _search {
	"query" : {
		"bool" : {
			"must" : [{
					"range" : {
						"maxReviewDate" : {
							"gte" : "2018-02-14 00:00:00"
						}
					}
				}, {
					"nested" : {
						"path" : "Reviews",
						"query" : {
							"term" : {
								"Reviews.User" : "John"
							}
						}
					}
				}
			]
		}
	}
}
```

---

<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:** [April 2, 2018, 4:06am UTC](https://discuss.elastic.co/t/bool-query-execution-order/122435/2 "2018-04-02T04:06:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
